@apipass/mongo-memory-server 0.0.36 → 0.0.37
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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/mongoose-config-service.mock.d.ts +5 -0
- package/lib/mongoose-config-service.mock.js +26 -0
- package/lib/mongoose-config-service.mock.js.map +1 -0
- package/package.json +3 -3
- package/lib/mongodb-memory-server.setup.d.ts +0 -11
- package/lib/mongodb-memory-server.setup.js +0 -52
- package/lib/mongodb-memory-server.setup.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './mongoose-config-service.mock';
|
package/lib/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./mongoose-config-service.mock"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MongooseModuleOptions, MongooseOptionsFactory } from '@nestjs/mongoose';
|
|
2
|
+
export declare class MongooseConfigServiceMock implements MongooseOptionsFactory {
|
|
3
|
+
private static mongoDb;
|
|
4
|
+
createMongooseOptions(options?: MongooseModuleOptions): Promise<MongooseModuleOptions>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MongooseConfigServiceMock = void 0;
|
|
13
|
+
const mongodb_memory_server_1 = require("mongodb-memory-server");
|
|
14
|
+
class MongooseConfigServiceMock {
|
|
15
|
+
createMongooseOptions() {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
17
|
+
if (!MongooseConfigServiceMock.mongoDb) {
|
|
18
|
+
MongooseConfigServiceMock.mongoDb = yield mongodb_memory_server_1.MongoMemoryServer.create();
|
|
19
|
+
}
|
|
20
|
+
return Object.assign({ uri: MongooseConfigServiceMock.mongoDb.getUri(), autoCreate: true }, options);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.MongooseConfigServiceMock = MongooseConfigServiceMock;
|
|
25
|
+
MongooseConfigServiceMock.mongoDb = null;
|
|
26
|
+
//# sourceMappingURL=mongoose-config-service.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoose-config-service.mock.js","sourceRoot":"","sources":["../src/mongoose-config-service.mock.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AAGzD,MAAa,yBAAyB;IAG9B,qBAAqB;6DAAE,UAAiC,EAAE;YAC9D,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,CAAC;gBACvC,yBAAyB,CAAC,OAAO,GAAG,MAAM,yCAAiB,CAAC,MAAM,EAAE,CAAA;YACtE,CAAC;YACD,uBACE,GAAG,EAAE,yBAAyB,CAAC,OAAO,CAAC,MAAM,EAAE,EAC/C,UAAU,EAAE,IAAI,IACb,OAAO,EACX;QACH,CAAC;KAAA;;AAZH,8DAaC;AAZgB,iCAAO,GAA6B,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apipass/mongo-memory-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"lib": "lib"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"mongoose": "
|
|
11
|
+
"@nestjs/mongoose": "10.0.10"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"mongodb-memory-server": "10.0.0"
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"tsc": "tsc"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a97365e39f1fd0956ba05c4c3f1c8a0d9dea9c02"
|
|
26
26
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MongoMemoryServer } from 'mongodb-memory-server';
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
export declare abstract class MongodbMemoryServerSetup {
|
|
4
|
-
mongoDb: MongoMemoryServer | null;
|
|
5
|
-
client: typeof mongoose | null;
|
|
6
|
-
abstract databaseName: string;
|
|
7
|
-
initialize(): Promise<void>;
|
|
8
|
-
connectDatabase(): Promise<void>;
|
|
9
|
-
abstract loadInitialData(): Promise<void>;
|
|
10
|
-
disconnectDatabase(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MongodbMemoryServerSetup = void 0;
|
|
13
|
-
const mongodb_memory_server_1 = require("mongodb-memory-server");
|
|
14
|
-
const mongoose = require("mongoose");
|
|
15
|
-
class MongodbMemoryServerSetup {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.mongoDb = null;
|
|
18
|
-
this.client = null;
|
|
19
|
-
}
|
|
20
|
-
initialize() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
yield this.connectDatabase();
|
|
23
|
-
yield this.loadInitialData();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
connectDatabase() {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
if (!this.mongoDb) {
|
|
29
|
-
this.mongoDb = yield mongodb_memory_server_1.MongoMemoryServer.create();
|
|
30
|
-
}
|
|
31
|
-
this.client = yield mongoose.connect(this.mongoDb.getUri(), {
|
|
32
|
-
dbName: this.databaseName,
|
|
33
|
-
autoCreate: true
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
disconnectDatabase() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (this.client) {
|
|
40
|
-
yield mongoose.connection.dropDatabase();
|
|
41
|
-
yield mongoose.disconnect();
|
|
42
|
-
}
|
|
43
|
-
if (this.mongoDb) {
|
|
44
|
-
yield this.mongoDb.stop();
|
|
45
|
-
}
|
|
46
|
-
this.client = null;
|
|
47
|
-
this.mongoDb = null;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.MongodbMemoryServerSetup = MongodbMemoryServerSetup;
|
|
52
|
-
//# sourceMappingURL=mongodb-memory-server.setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-memory-server.setup.js","sourceRoot":"","sources":["../src/mongodb-memory-server.setup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AACzD,qCAAoC;AAEpC,MAAsB,wBAAwB;IAA9C;QACS,YAAO,GAA6B,IAAI,CAAA;QACxC,WAAM,GAA2B,IAAI,CAAA;IA+B9C,CAAC;IA5Bc,UAAU;;YACrB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAA;YAC5B,MAAM,IAAI,CAAC,eAAe,EAAE,CAAA;QAC9B,CAAC;KAAA;IAEY,eAAe;;YAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,OAAO,GAAG,MAAM,yCAAiB,CAAC,MAAM,EAAE,CAAA;YACjD,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;gBAC1D,MAAM,EAAE,IAAI,CAAC,YAAY;gBACzB,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;KAAA;IAIY,kBAAkB;;YAC7B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,MAAM,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,CAAA;gBACxC,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAA;YAC7B,CAAC;YACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;YAC3B,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACrB,CAAC;KAAA;CACF;AAjCD,4DAiCC"}
|