npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

next-auth-couchbase-adapter

v0.0.7

Published

Couchbase adapter for next-auth.

Downloads

8

Readme

Overview

This is the Couchbase Adapter for next-auth. This package can only be used in conjunction with the primary next-auth package. It is not a standalone package.

This adapter uses Ottoman ODM to connect next-auth to Couchbase.

Getting Started

  1. Install [email protected] and next-auth-couchbase-adapter, as well as ottoman. (Ottoman depends on Couchbase Node SDK, which is included as a dep in ottoman, so no need to install couchbase)
npm install [email protected] next-auth-couchbase-adapter ottoman
  1. Add this adapter to your pages/api/[...nextauth].ts next-auth configuration object.
import NextAuth, { Profile } from "next-auth";
import { OAuthConfig } from "next-auth/providers";
import Google from "next-auth/providers/google";
import CouchbaseAdapter, { adapterOptions } from "next-auth-couchbase-adapter";

const options: adapterOptions = {
  connectionString: "couchbase://localhost",
  bucketName: "connext",
  username: "Administrator",
  password: "1234567890",
  // ensure collections and indexes for quick setup in development (DON'T DO THIS IN PRODUCTION)
  ensureCollections: true,
  ensureIndexes: true,
};

export default NextAuth({
  // Configure one or more authentication providers
  providers: [
    Google({
      clientId: process.env.GOOGLE_ID as string,
      clientSecret: process.env.GOOGLE_SECRET as string,
    }) as OAuthConfig<Profile>,
  ],
  jwt: {
    secret: process.env.SECRET as string,
  },
  adapter: CouchbaseAdapter(options),

  // ...
})

Custom Collection Names

In the options objection you can add a collectionNames property to name the next-auth collections (models) whatever you would like:

const options: adapterOptions = {
  connectionString: "couchbase://localhost",
  // ...
  collectionNames: {
    User: "WhateverUser", // default is User
    Account: "WhateverAccount", // default is UserAccount
    Session: "WhateverSession", // default is UserSession
    VerificationToken: "WhateverToken", // default is UserVerificationToken
  },
}

Using your own ottoman instance

You can use your own ottoman instance if you already have a module setup that you would like to reuse, just need a reference to the Ottoman instance and make sure you export your connection settings so the couchbase adapter can connect if needed.

// somewhere.ts <--- your module file

const ottoman = new Ottoman()

const connectionOptions = {
  connectionString: "couchbase://localhost",
  bucketName: "connext",
  username: "Administrator",
  password: "1234567890",
}

export { connectionOptions }
export default ottoman

and then in the nextauth route:

// [...nextauth].ts file
import yourOttomanInstance, { connectionOptions } from "somewhere"

const options: adapterOptions = {
  instance: yourOttomanInstance,
  ...connectionOptions,
}

Contributing

We're open to all community contributions! If you'd like to contribute in any way, please read our Contributing Guide.

License

ISC