@auth/mongodb-adapter
Advanced tools
Comparing version 3.0.0 to 3.1.0
/** | ||
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}> | ||
* <p style={{fontWeight: "normal"}}>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <p>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <a href="https://www.mongodb.com"> | ||
@@ -38,5 +38,5 @@ * <img style={{display: "block"}} src="https://authjs.dev/img/adapters/mongodb.svg" width="30" /> | ||
export declare const format: { | ||
/** Takes a mongoDB object and returns a plain old JavaScript object */ | ||
/** Takes a MongoDB object and returns a plain old JavaScript object */ | ||
from<T = Record<string, unknown>>(object: Record<string, any>): T; | ||
/** Takes a plain old JavaScript object and turns it into a mongoDB object */ | ||
/** Takes a plain old JavaScript object and turns it into a MongoDB object */ | ||
to<T_1 = Record<string, unknown>>(object: Record<string, any>): T_1 & { | ||
@@ -46,57 +46,3 @@ _id: ObjectId; | ||
}; | ||
/** | ||
* ## Setup | ||
* | ||
* The MongoDB adapter does not handle connections automatically, so you will have to make sure that you pass the Adapter a `MongoClient` that is connected already. Below you can see an example how to do this. | ||
* | ||
* ### Add the MongoDB client | ||
* | ||
* ```ts | ||
* // This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb | ||
* import { MongoClient } from "mongodb" | ||
* | ||
* if (!process.env.MONGODB_URI) { | ||
* throw new Error('Invalid/Missing environment variable: "MONGODB_URI"') | ||
* } | ||
* | ||
* const uri = process.env.MONGODB_URI | ||
* const options = {} | ||
* | ||
* let client | ||
* let clientPromise: Promise<MongoClient> | ||
* | ||
* if (process.env.NODE_ENV === "development") { | ||
* // In development mode, use a global variable so that the value | ||
* // is preserved across module reloads caused by HMR (Hot Module Replacement). | ||
* if (!global._mongoClientPromise) { | ||
* client = new MongoClient(uri, options) | ||
* global._mongoClientPromise = client.connect() | ||
* } | ||
* clientPromise = global._mongoClientPromise | ||
* } else { | ||
* // In production mode, it's best to not use a global variable. | ||
* client = new MongoClient(uri, options) | ||
* clientPromise = client.connect() | ||
* } | ||
* | ||
* // Export a module-scoped MongoClient promise. By doing this in a | ||
* // separate module, the client can be shared across functions. | ||
* export default clientPromise | ||
* ``` | ||
* | ||
* ### Configure Auth.js | ||
* | ||
* ```js | ||
* import NextAuth from "next-auth" | ||
* import { MongoDBAdapter } from "@auth/mongodb-adapter" | ||
* import clientPromise from "../../../lib/mongodb" | ||
* | ||
* // For more information on each option (and a full list of options) go to | ||
* // https://authjs.dev/reference/providers/oauth | ||
* export default NextAuth({ | ||
* adapter: MongoDBAdapter(clientPromise), | ||
* }) | ||
* ``` | ||
**/ | ||
export declare function MongoDBAdapter(client: Promise<MongoClient>, options?: MongoDBAdapterOptions): Adapter; | ||
//# sourceMappingURL=index.d.ts.map |
60
index.js
/** | ||
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}> | ||
* <p style={{fontWeight: "normal"}}>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <p>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <a href="https://www.mongodb.com"> | ||
@@ -25,3 +25,3 @@ * <img style={{display: "block"}} src="https://authjs.dev/img/adapters/mongodb.svg" width="30" /> | ||
export const format = { | ||
/** Takes a mongoDB object and returns a plain old JavaScript object */ | ||
/** Takes a MongoDB object and returns a plain old JavaScript object */ | ||
from(object) { | ||
@@ -43,3 +43,3 @@ const newObject = {}; | ||
}, | ||
/** Takes a plain old JavaScript object and turns it into a mongoDB object */ | ||
/** Takes a plain old JavaScript object and turns it into a MongoDB object */ | ||
to(object) { | ||
@@ -67,56 +67,2 @@ const newObject = { | ||
} | ||
/** | ||
* ## Setup | ||
* | ||
* The MongoDB adapter does not handle connections automatically, so you will have to make sure that you pass the Adapter a `MongoClient` that is connected already. Below you can see an example how to do this. | ||
* | ||
* ### Add the MongoDB client | ||
* | ||
* ```ts | ||
* // This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb | ||
* import { MongoClient } from "mongodb" | ||
* | ||
* if (!process.env.MONGODB_URI) { | ||
* throw new Error('Invalid/Missing environment variable: "MONGODB_URI"') | ||
* } | ||
* | ||
* const uri = process.env.MONGODB_URI | ||
* const options = {} | ||
* | ||
* let client | ||
* let clientPromise: Promise<MongoClient> | ||
* | ||
* if (process.env.NODE_ENV === "development") { | ||
* // In development mode, use a global variable so that the value | ||
* // is preserved across module reloads caused by HMR (Hot Module Replacement). | ||
* if (!global._mongoClientPromise) { | ||
* client = new MongoClient(uri, options) | ||
* global._mongoClientPromise = client.connect() | ||
* } | ||
* clientPromise = global._mongoClientPromise | ||
* } else { | ||
* // In production mode, it's best to not use a global variable. | ||
* client = new MongoClient(uri, options) | ||
* clientPromise = client.connect() | ||
* } | ||
* | ||
* // Export a module-scoped MongoClient promise. By doing this in a | ||
* // separate module, the client can be shared across functions. | ||
* export default clientPromise | ||
* ``` | ||
* | ||
* ### Configure Auth.js | ||
* | ||
* ```js | ||
* import NextAuth from "next-auth" | ||
* import { MongoDBAdapter } from "@auth/mongodb-adapter" | ||
* import clientPromise from "../../../lib/mongodb" | ||
* | ||
* // For more information on each option (and a full list of options) go to | ||
* // https://authjs.dev/reference/providers/oauth | ||
* export default NextAuth({ | ||
* adapter: MongoDBAdapter(clientPromise), | ||
* }) | ||
* ``` | ||
**/ | ||
export function MongoDBAdapter(client, options = {}) { | ||
@@ -123,0 +69,0 @@ const { collections } = options; |
{ | ||
"name": "@auth/mongodb-adapter", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "MongoDB adapter for Auth.js", | ||
@@ -37,3 +37,3 @@ "homepage": "https://authjs.dev", | ||
"dependencies": { | ||
"@auth/core": "0.30.0" | ||
"@auth/core": "0.31.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "peerDependencies": { |
@@ -21,3 +21,3 @@ <p align="center"> | ||
<a href="https://github.com/nextauthjs/next-auth/stargazers"> | ||
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" /> | ||
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="GitHub Stars" /> | ||
</a> | ||
@@ -24,0 +24,0 @@ </p> |
/** | ||
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: 16}}> | ||
* <p style={{fontWeight: "normal"}}>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <p>Official <a href="https://www.mongodb.com">MongoDB</a> adapter for Auth.js / NextAuth.js.</p> | ||
* <a href="https://www.mongodb.com"> | ||
@@ -55,3 +55,3 @@ * <img style={{display: "block"}} src="https://authjs.dev/img/adapters/mongodb.svg" width="30" /> | ||
export const format = { | ||
/** Takes a mongoDB object and returns a plain old JavaScript object */ | ||
/** Takes a MongoDB object and returns a plain old JavaScript object */ | ||
from<T = Record<string, unknown>>(object: Record<string, any>): T { | ||
@@ -71,3 +71,3 @@ const newObject: Record<string, unknown> = {} | ||
}, | ||
/** Takes a plain old JavaScript object and turns it into a mongoDB object */ | ||
/** Takes a plain old JavaScript object and turns it into a MongoDB object */ | ||
to<T = Record<string, unknown>>(object: Record<string, any>) { | ||
@@ -93,56 +93,2 @@ const newObject: Record<string, unknown> = { | ||
/** | ||
* ## Setup | ||
* | ||
* The MongoDB adapter does not handle connections automatically, so you will have to make sure that you pass the Adapter a `MongoClient` that is connected already. Below you can see an example how to do this. | ||
* | ||
* ### Add the MongoDB client | ||
* | ||
* ```ts | ||
* // This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb | ||
* import { MongoClient } from "mongodb" | ||
* | ||
* if (!process.env.MONGODB_URI) { | ||
* throw new Error('Invalid/Missing environment variable: "MONGODB_URI"') | ||
* } | ||
* | ||
* const uri = process.env.MONGODB_URI | ||
* const options = {} | ||
* | ||
* let client | ||
* let clientPromise: Promise<MongoClient> | ||
* | ||
* if (process.env.NODE_ENV === "development") { | ||
* // In development mode, use a global variable so that the value | ||
* // is preserved across module reloads caused by HMR (Hot Module Replacement). | ||
* if (!global._mongoClientPromise) { | ||
* client = new MongoClient(uri, options) | ||
* global._mongoClientPromise = client.connect() | ||
* } | ||
* clientPromise = global._mongoClientPromise | ||
* } else { | ||
* // In production mode, it's best to not use a global variable. | ||
* client = new MongoClient(uri, options) | ||
* clientPromise = client.connect() | ||
* } | ||
* | ||
* // Export a module-scoped MongoClient promise. By doing this in a | ||
* // separate module, the client can be shared across functions. | ||
* export default clientPromise | ||
* ``` | ||
* | ||
* ### Configure Auth.js | ||
* | ||
* ```js | ||
* import NextAuth from "next-auth" | ||
* import { MongoDBAdapter } from "@auth/mongodb-adapter" | ||
* import clientPromise from "../../../lib/mongodb" | ||
* | ||
* // For more information on each option (and a full list of options) go to | ||
* // https://authjs.dev/reference/providers/oauth | ||
* export default NextAuth({ | ||
* adapter: MongoDBAdapter(clientPromise), | ||
* }) | ||
* ``` | ||
**/ | ||
export function MongoDBAdapter( | ||
@@ -149,0 +95,0 @@ client: Promise<MongoClient>, |
Sorry, the diff of this file is not supported yet
17587
415
+ Added@auth/core@0.31.0(transitive)
+ Added@panva/hkdf@1.1.1(transitive)
+ Addedjose@5.4.0(transitive)
+ Addedoauth4webapi@2.10.4(transitive)
- Removed@auth/core@0.30.0(transitive)
- Removed@panva/hkdf@1.2.0(transitive)
- Removedjose@5.4.1(transitive)
- Removedoauth4webapi@2.11.1(transitive)
Updated@auth/core@0.31.0