@lowdefy/connection-mongodb 4.0.0-alpha.22 → 4.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { MongoClient } from 'mongodb';
16
+ import { MongoDBAdapter as NextAuthMongoDBAdapter } from '@next-auth/mongodb-adapter';
17
+ /*
18
+ Default collections are:
19
+ {
20
+ Users: "users",
21
+ Accounts: "accounts",
22
+ Sessions: "sessions",
23
+ VerificationTokens: "verification_tokens",
24
+ }
25
+ */ // TODO: Docs: MongoDB database name should be in databaseUri
26
+ function MongoDBAdapter({ properties }) {
27
+ const { databaseUri , mongoDBClientOptions , collections } = properties;
28
+ const clientPromise = new MongoClient(databaseUri, mongoDBClientOptions).connect();
29
+ return NextAuthMongoDBAdapter(clientPromise, collections);
30
+ }
31
+ export default MongoDBAdapter;
@@ -0,0 +1,2 @@
1
+ import MongoDBAdapter from './adapters/MongoDBAdapter/MongoDBAdapter.js';
2
+ export { MongoDBAdapter };
@@ -16,11 +16,7 @@
16
16
  async function getCollection({ connection }) {
17
17
  let client;
18
18
  const { collection , databaseUri , databaseName , options } = connection;
19
- client = new MongoClient(databaseUri, {
20
- ...options,
21
- useNewUrlParser: true,
22
- useUnifiedTopology: true
23
- });
19
+ client = new MongoClient(databaseUri, options);
24
20
  await client.connect();
25
21
  try {
26
22
  const db = client.db(databaseName);
package/dist/types.js CHANGED
@@ -12,8 +12,12 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import * as connections from './connections.js';
15
+ */ import * as adapters from './auth/adapters.js';
16
+ import * as connections from './connections.js';
16
17
  export default {
18
+ auth: {
19
+ adapters: Object.keys(adapters)
20
+ },
17
21
  connections: Object.keys(connections),
18
22
  requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)).flat()
19
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/connection-mongodb",
3
- "version": "4.0.0-alpha.22",
3
+ "version": "4.0.0-alpha.23",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "type": "module",
30
30
  "exports": {
31
+ "./auth/adapters": "./dist/auth/adapters.js",
31
32
  "./connections": "./dist/connections.js",
32
33
  "./types": "./dist/types.js"
33
34
  },
@@ -42,12 +43,13 @@
42
43
  "test": "jest --coverage"
43
44
  },
44
45
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-alpha.22",
46
+ "@lowdefy/helpers": "4.0.0-alpha.23",
47
+ "@next-auth/mongodb-adapter": "1.0.3",
46
48
  "mongodb": "4.6.0",
47
49
  "saslprep": "1.0.3"
48
50
  },
49
51
  "devDependencies": {
50
- "@lowdefy/ajv": "4.0.0-alpha.22",
52
+ "@lowdefy/ajv": "4.0.0-alpha.23",
51
53
  "@shelf/jest-mongodb": "2.2.2",
52
54
  "@swc/cli": "0.1.57",
53
55
  "@swc/core": "1.2.194",
@@ -57,5 +59,5 @@
57
59
  "publishConfig": {
58
60
  "access": "public"
59
61
  },
60
- "gitHead": "66ce29562c016a8bcf0cbea4bbbbb71d364ae995"
62
+ "gitHead": "1bb110fb4432267efb199df926bae6bb735209ca"
61
63
  }