mongodb-dynamic-api 2.3.9 → 2.3.10
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/CHANGELOG.md +2 -0
- package/package.json +4 -1
- package/src/version.json +1 -1
- package/test/dynamic-api-for-root.e2e-spec.d.ts +1 -0
- package/test/dynamic-api-for-root.e2e-spec.js +93 -0
- package/test/dynamic-api-for-root.e2e-spec.js.map +1 -0
- package/test/e2e.setup.d.ts +10 -0
- package/test/e2e.setup.js +64 -0
- package/test/e2e.setup.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
|
|
3
|
+
## [2.3.10](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.9...v2.3.10) (2024-05-11)
|
|
4
|
+
|
|
3
5
|
## [2.3.9](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.8...v2.3.9) (2024-05-09)
|
|
4
6
|
|
|
5
7
|
## [2.3.8](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.7...v2.3.8) (2024-05-08)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-dynamic-api",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.10",
|
|
4
4
|
"description": "Auto generated CRUD API for MongoDB using NestJS",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "index.js",
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
13
13
|
"test": "jest --runInBand",
|
|
14
14
|
"test-cov": "jest --runInBand --coverage",
|
|
15
|
+
"test-e2e": "jest --runInBand --config ./libs/dynamic-api/test/jest-e2e.json",
|
|
16
|
+
"test-e2e:ci": "jest --ci --runInBand --config ./libs/dynamic-api/test/jest-e2e.json",
|
|
15
17
|
"test:ci:junit": "jest --ci --runInBand --coverage --testResultsProcessor=jest-junit",
|
|
16
18
|
"test:ci:sonar": "jest --ci --runInBand --coverage --testResultsProcessor=jest-sonar-reporter",
|
|
17
19
|
"pre-release-tag": "git tag -f prerelease && git push -f origin prerelease",
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
"cache-manager": "^5.4.0",
|
|
53
55
|
"class-transformer": "^0.5.1",
|
|
54
56
|
"class-validator": "^0.14.1",
|
|
57
|
+
"dotenv": "^16.4.5",
|
|
55
58
|
"lodash": "^4.17.21",
|
|
56
59
|
"mongoose": "^8.1.1",
|
|
57
60
|
"passport": "^0.7.0",
|
package/src/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
|
4
|
+
const src_1 = require("../src");
|
|
5
|
+
const e2e_setup_1 = require("./e2e.setup");
|
|
6
|
+
require("dotenv/config");
|
|
7
|
+
describe('DynamicApiModule forRoot (e2e)', () => {
|
|
8
|
+
let app;
|
|
9
|
+
const uri = process.env.MONGO_DB_URL;
|
|
10
|
+
class UserEntity extends src_1.BaseEntity {
|
|
11
|
+
}
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
await (0, e2e_setup_1.closeTestingApp)();
|
|
14
|
+
});
|
|
15
|
+
it('should initialize dynamic api module state with default options', async () => {
|
|
16
|
+
const moduleRef = await testing_1.Test.createTestingModule({
|
|
17
|
+
imports: [src_1.DynamicApiModule.forRoot(uri)],
|
|
18
|
+
}).compile();
|
|
19
|
+
app = await (0, e2e_setup_1.createTestingApp)(moduleRef);
|
|
20
|
+
expect(app).toBeDefined();
|
|
21
|
+
expect(src_1.DynamicApiModule.state.get()).toStrictEqual({
|
|
22
|
+
uri,
|
|
23
|
+
initialized: true,
|
|
24
|
+
isGlobalCacheEnabled: true,
|
|
25
|
+
connectionName: 'dynamic-api-connection',
|
|
26
|
+
cacheExcludedPaths: [],
|
|
27
|
+
credentials: null,
|
|
28
|
+
isAuthEnabled: false,
|
|
29
|
+
jwtSecret: undefined,
|
|
30
|
+
routesConfig: {
|
|
31
|
+
defaults: [
|
|
32
|
+
'GetMany',
|
|
33
|
+
'GetOne',
|
|
34
|
+
'CreateMany',
|
|
35
|
+
'CreateOne',
|
|
36
|
+
'UpdateMany',
|
|
37
|
+
'UpdateOne',
|
|
38
|
+
'ReplaceOne',
|
|
39
|
+
'DuplicateMany',
|
|
40
|
+
'DuplicateOne',
|
|
41
|
+
'DeleteMany',
|
|
42
|
+
'DeleteOne',
|
|
43
|
+
],
|
|
44
|
+
excluded: [],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('should initialize dynamic api module state with custom options', async () => {
|
|
49
|
+
const dynamicApiForRootOptions = {
|
|
50
|
+
useGlobalCache: false,
|
|
51
|
+
cacheOptions: {
|
|
52
|
+
excludePaths: ['/fake-path'],
|
|
53
|
+
},
|
|
54
|
+
useAuth: {
|
|
55
|
+
userEntity: UserEntity,
|
|
56
|
+
login: {
|
|
57
|
+
loginField: 'login',
|
|
58
|
+
passwordField: 'pass',
|
|
59
|
+
},
|
|
60
|
+
jwt: {
|
|
61
|
+
secret: 'custom-secret',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
routesConfig: {
|
|
65
|
+
defaults: ['GetMany', 'GetOne', 'CreateOne', 'UpdateOne', 'DeleteOne'],
|
|
66
|
+
excluded: ['CreateMany', 'UpdateMany', 'DeleteMany'],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const moduleRef = await testing_1.Test.createTestingModule({
|
|
70
|
+
imports: [src_1.DynamicApiModule.forRoot(uri, dynamicApiForRootOptions)],
|
|
71
|
+
}).compile();
|
|
72
|
+
app = await (0, e2e_setup_1.createTestingApp)(moduleRef);
|
|
73
|
+
expect(app).toBeDefined();
|
|
74
|
+
expect(src_1.DynamicApiModule.state.get()).toStrictEqual({
|
|
75
|
+
uri,
|
|
76
|
+
initialized: true,
|
|
77
|
+
isGlobalCacheEnabled: false,
|
|
78
|
+
connectionName: 'dynamic-api-connection',
|
|
79
|
+
cacheExcludedPaths: ['/fake-path'],
|
|
80
|
+
credentials: {
|
|
81
|
+
loginField: 'login',
|
|
82
|
+
passwordField: 'pass',
|
|
83
|
+
},
|
|
84
|
+
isAuthEnabled: true,
|
|
85
|
+
jwtSecret: 'custom-secret',
|
|
86
|
+
routesConfig: {
|
|
87
|
+
defaults: ['GetMany', 'GetOne', 'CreateOne', 'UpdateOne', 'DeleteOne'],
|
|
88
|
+
excluded: ['CreateMany', 'UpdateMany', 'DeleteMany'],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=dynamic-api-for-root.e2e-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-api-for-root.e2e-spec.js","sourceRoot":"","sources":["../../libs/dynamic-api/test/dynamic-api-for-root.e2e-spec.ts"],"names":[],"mappings":";;AACA,6CAAuC;AACvC,gCAAgF;AAChF,2CAAgE;AAChE,yBAAuB;AAEvB,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,IAAI,GAAqB,CAAC;IAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAErC,MAAM,UAAW,SAAQ,gBAAU;KAGlC;IAED,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,IAAA,2BAAe,GAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,SAAS,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC/C,OAAO,EAAE,CAAC,sBAAgB,CAAC,OAAO,CAAC,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GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC/C,OAAO,EAAE,CAAC,sBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;SACnE,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,GAAG,GAAG,MAAM,IAAA,4BAAgB,EAAC,SAAS,CAAC,CAAC;QAExC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,CAAC,sBAAgB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,aAAa,CAAC;YACjD,GAAG;YACH,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE,KAAK;YAC3B,cAAc,EAAE,wBAAwB;YACxC,kBAAkB,EAAE,CAAC,YAAY,CAAC;YAClC,WAAW,EAAE;gBACX,UAAU,EAAE,OAAO;gBACnB,aAAa,EAAE,MAAM;aACtB;YACD,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,eAAe;YAC1B,YAAY,EAAE;gBACZ,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC;gBACtE,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;aACrD;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TestingModule } from '@nestjs/testing';
|
|
2
|
+
export declare function createTestingApp(moduleRef: TestingModule, initMainCb?: (app: any) => Promise<void>): Promise<import("@nestjs/common").INestApplication<any>>;
|
|
3
|
+
export declare function closeTestingApp(): Promise<void>;
|
|
4
|
+
export declare const server: {
|
|
5
|
+
get: (path: string) => Promise<any>;
|
|
6
|
+
post: (path: string, body: any) => Promise<any>;
|
|
7
|
+
patch: (path: string, body: any) => Promise<any>;
|
|
8
|
+
put: (path: string, body: any) => Promise<any>;
|
|
9
|
+
delete: (path: string) => Promise<any>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.server = exports.closeTestingApp = exports.createTestingApp = void 0;
|
|
4
|
+
async function createTestingApp(moduleRef, initMainCb) {
|
|
5
|
+
global.app = moduleRef.createNestApplication();
|
|
6
|
+
if (initMainCb) {
|
|
7
|
+
await initMainCb(global.app);
|
|
8
|
+
}
|
|
9
|
+
return global.app.init();
|
|
10
|
+
}
|
|
11
|
+
exports.createTestingApp = createTestingApp;
|
|
12
|
+
const verifyApp = () => {
|
|
13
|
+
if (!global.app) {
|
|
14
|
+
throw new Error('App is not initialized');
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
async function closeTestingApp() {
|
|
18
|
+
if (!global.app) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
await global.app.close();
|
|
22
|
+
}
|
|
23
|
+
exports.closeTestingApp = closeTestingApp;
|
|
24
|
+
exports.server = {
|
|
25
|
+
get: async (path) => {
|
|
26
|
+
verifyApp();
|
|
27
|
+
return await global.app.getHttpServer()({
|
|
28
|
+
method: 'GET',
|
|
29
|
+
url: path,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
post: async (path, body) => {
|
|
33
|
+
verifyApp();
|
|
34
|
+
return await global.app.getHttpServer()({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
url: path,
|
|
37
|
+
payload: body,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
patch: async (path, body) => {
|
|
41
|
+
verifyApp();
|
|
42
|
+
return await global.app.getHttpServer()({
|
|
43
|
+
method: 'PATCH',
|
|
44
|
+
url: path,
|
|
45
|
+
payload: body,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
put: async (path, body) => {
|
|
49
|
+
verifyApp();
|
|
50
|
+
return await global.app.getHttpServer()({
|
|
51
|
+
method: 'PUT',
|
|
52
|
+
url: path,
|
|
53
|
+
payload: body,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
delete: async (path) => {
|
|
57
|
+
verifyApp();
|
|
58
|
+
return await global.app.getHttpServer()({
|
|
59
|
+
method: 'DELETE',
|
|
60
|
+
url: path,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=e2e.setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e.setup.js","sourceRoot":"","sources":["../../libs/dynamic-api/test/e2e.setup.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,gBAAgB,CACpC,SAAwB,EACxB,UAAwC;IAExC,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IAE/C,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAXD,4CAWC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC,CAAC;AAEK,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAND,0CAMC;AAEY,QAAA,MAAM,GAAG;IACpB,GAAG,EAAE,KAAK,EAAE,IAAY,EAAgB,EAAE;QACxC,SAAS,EAAE,CAAC;QACZ,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YACtC,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC;IACD,IA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