@prosopo/database 3.15.18 → 3.15.20
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.
- package/.turbo/turbo-build$colon$cjs.log +20 -17
- package/.turbo/turbo-build$colon$tsc.log +16 -16
- package/.turbo/turbo-build.log +21 -18
- package/CHANGELOG.md +24 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/base/index.js +1 -4
- package/dist/base/mongo.js +133 -137
- package/dist/base/mongoMemory.js +21 -21
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/base/index.cjs +4 -6
- package/dist/cjs/base/mongo.cjs +140 -143
- package/dist/cjs/base/mongoMemory.cjs +22 -22
- package/dist/cjs/databases/captcha.cjs +213 -256
- package/dist/cjs/databases/centralDbStreamer.cjs +148 -170
- package/dist/cjs/databases/client.cjs +46 -62
- package/dist/cjs/databases/index.cjs +19 -19
- package/dist/cjs/databases/provider.cjs +1827 -2251
- package/dist/cjs/index.cjs +25 -23
- package/dist/cjs/mongooseOptions.cjs +59 -58
- package/dist/cjs/redisCache.cjs +432 -474
- package/dist/databases/captcha.js +210 -253
- package/dist/databases/centralDbStreamer.js +147 -169
- package/dist/databases/client.js +44 -60
- package/dist/databases/index.js +10 -14
- package/dist/databases/provider.d.ts +4 -4
- package/dist/databases/provider.d.ts.map +1 -1
- package/dist/databases/provider.js +1823 -2247
- package/dist/databases/provider.js.map +1 -1
- package/dist/index.js +9 -18
- package/dist/mongooseOptions.js +59 -59
- package/dist/redisCache.js +432 -474
- package/package.json +14 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.20 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -33,21 +33,24 @@ ViteCommonJSConfig: .
|
|
|
33
33
|
'@prosopo/api'
|
|
34
34
|
]
|
|
35
35
|
}
|
|
36
|
-
[
|
|
36
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
37
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
37
38
|
Bundle build started
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[32m✓[39m 11 modules transformed.
|
|
39
|
+
[2K
|
|
40
|
+
✓ 12 modules transformed.
|
|
41
41
|
rendering chunks...
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
computing gzip size...
|
|
43
|
+
dist/cjs/base/index.cjs 0.22 kB │ gzip: 0.10 kB
|
|
44
|
+
dist/cjs/base/mongoMemory.cjs 0.66 kB │ gzip: 0.32 kB
|
|
45
|
+
dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
|
|
46
|
+
dist/cjs/databases/index.cjs 1.14 kB │ gzip: 0.32 kB
|
|
47
|
+
dist/cjs/index.cjs 1.49 kB │ gzip: 0.45 kB
|
|
48
|
+
dist/cjs/databases/client.cjs 1.57 kB │ gzip: 0.69 kB
|
|
49
|
+
dist/cjs/mongooseOptions.cjs 2.65 kB │ gzip: 1.15 kB
|
|
50
|
+
dist/cjs/base/mongo.cjs 4.25 kB │ gzip: 1.30 kB
|
|
51
|
+
dist/cjs/databases/centralDbStreamer.cjs 5.29 kB │ gzip: 1.30 kB
|
|
52
|
+
dist/cjs/databases/captcha.cjs 7.16 kB │ gzip: 2.18 kB
|
|
53
|
+
dist/cjs/redisCache.cjs 14.09 kB │ gzip: 4.09 kB
|
|
54
|
+
dist/cjs/databases/provider.cjs 60.22 kB │ gzip: 11.96 kB
|
|
55
|
+
|
|
56
|
+
[32m✓ built in 98ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.20 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
8:59:38 PM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -17,31 +17,31 @@
|
|
|
17
17
|
* ../types-database/tsconfig.json
|
|
18
18
|
* tsconfig.json
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
8:59:38 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
8:59:38 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
8:59:38 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
8:59:38 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
8:59:38 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
8:59:38 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
8:59:38 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/batches.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
8:59:38 PM - Project '../api-route/tsconfig.json' is up to date because newest input '../api-route/src/apiRoutes.ts' is older than output '../api-route/tsconfig.tsbuildinfo'
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
8:59:38 PM - Project '../redis-client/tsconfig.json' is up to date because newest input '../redis-client/src/index.ts' is older than output '../redis-client/tsconfig.tsbuildinfo'
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
8:59:38 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
8:59:38 PM - Project '../user-access-policy/tsconfig.json' is up to date because newest input '../user-access-policy/src/ruleRecord.ts' is older than output '../user-access-policy/tsconfig.tsbuildinfo'
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
8:59:39 PM - Project '../types-database/tsconfig.json' is up to date because newest input '../types-database/src/types/bannedDomain.ts' is older than output '../types-database/tsconfig.tsbuildinfo'
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
8:59:39 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
8:59:39 PM - Building project '/home/runner/work/captcha/captcha/packages/database/tsconfig.json'...
|
|
47
47
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.20 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/database@3.15.
|
|
6
|
+
> @prosopo/database@3.15.20 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -37,21 +37,24 @@ ViteEsmConfig: .
|
|
|
37
37
|
'@prosopo/api'
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
|
-
[
|
|
40
|
+
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
41
|
+
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
41
42
|
Bundle build started
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[32m✓[39m 11 modules transformed.
|
|
43
|
+
[2K
|
|
44
|
+
✓ 12 modules transformed.
|
|
45
45
|
rendering chunks...
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
computing gzip size...
|
|
47
|
+
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
48
|
+
dist/base/index.js 0.14 kB │ gzip: 0.08 kB
|
|
49
|
+
dist/base/mongoMemory.js 0.60 kB │ gzip: 0.30 kB
|
|
50
|
+
dist/databases/index.js 0.77 kB │ gzip: 0.27 kB
|
|
51
|
+
dist/index.js 0.86 kB │ gzip: 0.31 kB
|
|
52
|
+
dist/databases/client.js 1.47 kB │ gzip: 0.68 kB
|
|
53
|
+
dist/mongooseOptions.js 2.56 kB │ gzip: 1.12 kB
|
|
54
|
+
dist/base/mongo.js 3.99 kB │ gzip: 1.21 kB
|
|
55
|
+
dist/databases/centralDbStreamer.js 5.23 kB │ gzip: 1.28 kB
|
|
56
|
+
dist/databases/captcha.js 7.08 kB │ gzip: 2.17 kB
|
|
57
|
+
dist/redisCache.js 14.07 kB │ gzip: 4.09 kB
|
|
58
|
+
dist/databases/provider.js 59.00 kB │ gzip: 11.94 kB
|
|
59
|
+
|
|
60
|
+
[32m✓ built in 101ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @prosopo/database
|
|
2
2
|
|
|
3
|
+
## 3.15.20
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- e14fce6: chore(deps): bump vite to 6.4.3 and mongoose to 8.24.1, and adjust types for the mongoose 8.24 Document/ObjectId changes
|
|
7
|
+
- Updated dependencies [2c47bb7]
|
|
8
|
+
- Updated dependencies [0e1171c]
|
|
9
|
+
- Updated dependencies [103318c]
|
|
10
|
+
- Updated dependencies [270a8d8]
|
|
11
|
+
- Updated dependencies [e14fce6]
|
|
12
|
+
- @prosopo/util@3.3.5
|
|
13
|
+
- @prosopo/types@4.10.0
|
|
14
|
+
- @prosopo/types-database@4.11.17
|
|
15
|
+
- @prosopo/common@3.1.48
|
|
16
|
+
- @prosopo/redis-client@1.0.30
|
|
17
|
+
- @prosopo/user-access-policy@3.12.9
|
|
18
|
+
- @prosopo/logger@2.0.4
|
|
19
|
+
|
|
20
|
+
## 3.15.19
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [c61dfb5]
|
|
24
|
+
- @prosopo/user-access-policy@3.12.8
|
|
25
|
+
- @prosopo/types-database@4.11.16
|
|
26
|
+
|
|
3
27
|
## 3.15.18
|
|
4
28
|
### Patch Changes
|
|
5
29
|
|
package/dist/base/index.js
CHANGED
package/dist/base/mongo.js
CHANGED
|
@@ -1,143 +1,139 @@
|
|
|
1
|
+
import { getMongoConnectionOptions } from "../mongooseOptions.js";
|
|
1
2
|
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { ProsopoDBError } from "@prosopo/common";
|
|
3
4
|
import { getLogger } from "@prosopo/logger";
|
|
4
5
|
import mongoose from "mongoose";
|
|
5
|
-
|
|
6
|
+
//#region src/base/mongo.ts
|
|
6
7
|
mongoose.set("strictQuery", false);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
msg: "Closing connection"
|
|
137
|
-
}));
|
|
138
|
-
await this.connection?.close();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
MongoDatabase
|
|
8
|
+
var DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
|
|
9
|
+
/**
|
|
10
|
+
* Returns a generic Mongo database layer
|
|
11
|
+
* @param {string} url The database endpoint
|
|
12
|
+
* @param {string} dbname The database name
|
|
13
|
+
* @return {MongoDatabase} Database layer
|
|
14
|
+
*/
|
|
15
|
+
var MongoDatabase = class {
|
|
16
|
+
constructor(url, dbname, authSource, logger) {
|
|
17
|
+
this.connected = false;
|
|
18
|
+
const parsedUrl = new URL(url || DEFAULT_ENDPOINT);
|
|
19
|
+
if (dbname) parsedUrl.pathname = dbname;
|
|
20
|
+
if (authSource) parsedUrl.searchParams.set("authSource", authSource);
|
|
21
|
+
this._url = parsedUrl.toString();
|
|
22
|
+
this.safeURL = this.url.replace(/\w+:\w+/, "<Credentials>");
|
|
23
|
+
this.dbname = dbname || parsedUrl.pathname.replace("/", "");
|
|
24
|
+
this.logger = logger || getLogger("info", "database:mongo");
|
|
25
|
+
}
|
|
26
|
+
get url() {
|
|
27
|
+
return this._url;
|
|
28
|
+
}
|
|
29
|
+
getConnection() {
|
|
30
|
+
if (!this.connection) throw new ProsopoDBError("DATABASE.CONNECTION_UNDEFINED", {
|
|
31
|
+
context: { failedFuncName: this.getConnection.name },
|
|
32
|
+
logger: this.logger
|
|
33
|
+
});
|
|
34
|
+
return this.connection;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @description Connect to the database and set the various tables
|
|
38
|
+
*/
|
|
39
|
+
async connect() {
|
|
40
|
+
this.logger.debug(() => ({
|
|
41
|
+
data: { mongoUrl: this.safeURL },
|
|
42
|
+
msg: "Connecting to database"
|
|
43
|
+
}));
|
|
44
|
+
try {
|
|
45
|
+
if (this.connected) {
|
|
46
|
+
this.logger.debug(() => ({
|
|
47
|
+
data: { mongoUrl: this.safeURL },
|
|
48
|
+
msg: "Database connection already open"
|
|
49
|
+
}));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (this.connecting) {
|
|
53
|
+
this.logger.debug(() => ({
|
|
54
|
+
data: { mongoUrl: this.safeURL },
|
|
55
|
+
msg: "Database connection in progress, waiting for it to finish"
|
|
56
|
+
}));
|
|
57
|
+
return this.connecting;
|
|
58
|
+
}
|
|
59
|
+
this.connecting = new Promise((resolve, reject) => {
|
|
60
|
+
const appName = fileURLToPath(import.meta.url);
|
|
61
|
+
const connection = mongoose.createConnection(this.url, getMongoConnectionOptions({
|
|
62
|
+
url: this.url,
|
|
63
|
+
appName,
|
|
64
|
+
dbName: this.dbname,
|
|
65
|
+
maxPoolSize: 50,
|
|
66
|
+
minPoolSize: 5
|
|
67
|
+
}));
|
|
68
|
+
const onConnected = () => {
|
|
69
|
+
this.logger.debug(() => ({
|
|
70
|
+
data: { mongoUrl: this.safeURL },
|
|
71
|
+
msg: "Database connection opened"
|
|
72
|
+
}));
|
|
73
|
+
this.connected = true;
|
|
74
|
+
this.connection = connection;
|
|
75
|
+
this.connecting = void 0;
|
|
76
|
+
resolve();
|
|
77
|
+
};
|
|
78
|
+
const onError = (err) => {
|
|
79
|
+
this.logger.error(() => ({
|
|
80
|
+
err,
|
|
81
|
+
data: { mongoUrl: this.safeURL },
|
|
82
|
+
msg: "Database error"
|
|
83
|
+
}));
|
|
84
|
+
this.connected = false;
|
|
85
|
+
this.connecting = void 0;
|
|
86
|
+
reject(err);
|
|
87
|
+
};
|
|
88
|
+
connection.once("open", onConnected);
|
|
89
|
+
connection.once("error", onError);
|
|
90
|
+
connection.on("disconnected", () => {
|
|
91
|
+
this.connected = false;
|
|
92
|
+
this.logger.debug(() => ({
|
|
93
|
+
data: { mongoUrl: this.safeURL },
|
|
94
|
+
msg: "Database disconnected"
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
connection.on("reconnected", () => {
|
|
98
|
+
this.connected = true;
|
|
99
|
+
this.logger.debug(() => ({
|
|
100
|
+
data: { mongoUrl: this.safeURL },
|
|
101
|
+
msg: "Database reconnected"
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
connection.on("close", () => {
|
|
105
|
+
this.connected = false;
|
|
106
|
+
this.logger.debug(() => ({
|
|
107
|
+
data: { mongoUrl: this.safeURL },
|
|
108
|
+
msg: "Database connection closed"
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
connection.on("fullsetup", () => {
|
|
112
|
+
this.connected = true;
|
|
113
|
+
this.logger.debug(() => ({
|
|
114
|
+
data: { mongoUrl: this.safeURL },
|
|
115
|
+
msg: "Database connection is fully setup"
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return this.connecting;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
this.logger.error(() => ({
|
|
122
|
+
err: e,
|
|
123
|
+
data: { mongoUrl: this.safeURL },
|
|
124
|
+
msg: "Database connection error"
|
|
125
|
+
}));
|
|
126
|
+
throw e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Close connection to the database */
|
|
130
|
+
async close() {
|
|
131
|
+
this.logger.debug(() => ({
|
|
132
|
+
data: { mongoUrl: this.safeURL },
|
|
133
|
+
msg: "Closing connection"
|
|
134
|
+
}));
|
|
135
|
+
await this.connection?.close();
|
|
136
|
+
}
|
|
143
137
|
};
|
|
138
|
+
//#endregion
|
|
139
|
+
export { MongoDatabase };
|
package/dist/base/mongoMemory.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
2
1
|
import { MongoDatabase } from "./mongo.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
MongoMemoryDatabase
|
|
2
|
+
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
3
|
+
//#region src/base/mongoMemory.ts
|
|
4
|
+
var MongoMemoryDatabase = class extends MongoDatabase {
|
|
5
|
+
constructor(_url, dbname, logger, authSource) {
|
|
6
|
+
super("", dbname, authSource, logger);
|
|
7
|
+
this._url = "";
|
|
8
|
+
}
|
|
9
|
+
async connect() {
|
|
10
|
+
if (!this.mongod) {
|
|
11
|
+
this.mongod = await MongoMemoryServer.create();
|
|
12
|
+
this._url = this.mongod.getUri();
|
|
13
|
+
}
|
|
14
|
+
await super.connect();
|
|
15
|
+
}
|
|
16
|
+
async close() {
|
|
17
|
+
await super.close();
|
|
18
|
+
await this.mongod?.stop();
|
|
19
|
+
this.mongod = void 0;
|
|
20
|
+
}
|
|
23
21
|
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { MongoMemoryDatabase };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
package/dist/cjs/base/index.cjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.MongoDatabase = mongo.MongoDatabase;
|
|
6
|
-
exports.MongoMemoryDatabase = mongoMemory.MongoMemoryDatabase;
|
|
1
|
+
const require_mongo = require("./mongo.cjs");
|
|
2
|
+
const require_mongoMemory = require("./mongoMemory.cjs");
|
|
3
|
+
exports.MongoDatabase = require_mongo.MongoDatabase;
|
|
4
|
+
exports.MongoMemoryDatabase = require_mongoMemory.MongoMemoryDatabase;
|