@nmxjs/app 1.0.45 → 1.0.47
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/dist/createTestNestApp.d.ts +6 -0
- package/dist/createTestNestApp.js +24 -0
- package/dist/createTestNestApp.js.map +1 -0
- package/dist/getTypeOrmModule.js +3 -24
- package/dist/getTypeOrmModule.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Test } from '@nestjs/testing';
|
|
2
|
+
import { ClientProxy } from '@nestjs/microservices';
|
|
3
|
+
export declare function createTestNestApp(module: Parameters<typeof Test.createTestingModule>[0]): Promise<{
|
|
4
|
+
app: import("@nestjs/common").INestApplication<any>;
|
|
5
|
+
client: ClientProxy;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTestNestApp = void 0;
|
|
4
|
+
const testing_1 = require("@nestjs/testing");
|
|
5
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
6
|
+
async function createTestNestApp(module) {
|
|
7
|
+
const clientKey = Symbol('CLIENT_KEY');
|
|
8
|
+
module.imports.push(microservices_1.ClientsModule.register([{ name: clientKey, transport: microservices_1.Transport.TCP }]));
|
|
9
|
+
const moduleFixture = await testing_1.Test.createTestingModule(module).compile();
|
|
10
|
+
const app = moduleFixture.createNestApplication();
|
|
11
|
+
app.connectMicroservice({
|
|
12
|
+
transport: microservices_1.Transport.TCP,
|
|
13
|
+
});
|
|
14
|
+
await app.startAllMicroservices();
|
|
15
|
+
await app.init();
|
|
16
|
+
const client = app.get(clientKey);
|
|
17
|
+
await client.connect();
|
|
18
|
+
return {
|
|
19
|
+
app,
|
|
20
|
+
client,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.createTestNestApp = createTestNestApp;
|
|
24
|
+
//# sourceMappingURL=createTestNestApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTestNestApp.js","sourceRoot":"","sources":["../src/createTestNestApp.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,yDAA8E;AAEvE,KAAK,UAAU,iBAAiB,CAAC,MAAsD;IAC5F,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAEvC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,6BAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,yBAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAE7F,MAAM,aAAa,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IACvE,MAAM,GAAG,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;IAElD,GAAG,CAAC,mBAAmB,CAAC;QACtB,SAAS,EAAE,yBAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IAEH,MAAM,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAClC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAEjB,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAc,SAAS,CAAC,CAAC;IAC/C,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IAEvB,OAAO;QACL,GAAG;QACH,MAAM;KACP,CAAC;AACJ,CAAC;AAtBD,8CAsBC"}
|
package/dist/getTypeOrmModule.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTypeOrmModule = void 0;
|
|
4
|
-
const typeorm_1 = require("typeorm");
|
|
5
|
-
const utils_1 = require("@nmxjs/utils");
|
|
6
|
-
const types_1 = require("@nmxjs/types");
|
|
7
|
-
const typeorm_2 = require("@nestjs/typeorm");
|
|
4
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
8
5
|
const config_1 = require("@nmxjs/config");
|
|
9
|
-
const getTypeOrmModule = () =>
|
|
10
|
-
useFactory: (config) => {
|
|
11
|
-
const options = Object.assign({ type: config.db.type, host: config.db.host, port: config.db.port, username: config.db.username, password: config.db.password, database: config.db.database, synchronize: true, autoLoadEntities: true }, (config.db.options ? config.db.options : {}));
|
|
12
|
-
return (0, utils_1.getEnvironment)() !== types_1.EnvironmentEnum.PRODUCTION && options.database
|
|
13
|
-
? new typeorm_1.DataSource({
|
|
14
|
-
type: options.type,
|
|
15
|
-
host: options.host,
|
|
16
|
-
port: options.port,
|
|
17
|
-
username: options.username,
|
|
18
|
-
password: options.password,
|
|
19
|
-
})
|
|
20
|
-
.initialize()
|
|
21
|
-
.then(ds => ds
|
|
22
|
-
.query(`CREATE DATABASE "${options.database}"`)
|
|
23
|
-
.then(() => ds)
|
|
24
|
-
.catch(() => ds))
|
|
25
|
-
.then(ds => ds.destroy())
|
|
26
|
-
.then(() => options)
|
|
27
|
-
: options;
|
|
28
|
-
},
|
|
6
|
+
const getTypeOrmModule = () => typeorm_1.TypeOrmModule.forRootAsync({
|
|
7
|
+
useFactory: (config) => (Object.assign({ type: config.db.type, host: config.db.host, port: config.db.port, username: config.db.username, password: config.db.password, database: config.db.database, synchronize: true, autoLoadEntities: true }, (config.db.options ? config.db.options : {}))),
|
|
29
8
|
inject: [config_1.configKey],
|
|
30
9
|
});
|
|
31
10
|
exports.getTypeOrmModule = getTypeOrmModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTypeOrmModule.js","sourceRoot":"","sources":["../src/getTypeOrmModule.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"getTypeOrmModule.js","sourceRoot":"","sources":["../src/getTypeOrmModule.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAChD,0CAAmD;AAE5C,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,uBAAa,CAAC,YAAY,CAAC;IACzB,UAAU,EAAE,CAAC,MAAe,EAAE,EAAE,CAAC,iBAC/B,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EACpB,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAC5B,WAAW,EAAE,IAAI,EACjB,gBAAgB,EAAE,IAAI,IACnB,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAC/C;IACF,MAAM,EAAE,CAAC,kBAAS,CAAC;CACpB,CAAC,CAAC;AAdQ,QAAA,gBAAgB,oBAcxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './createNestApp';
|
|
|
4
4
|
export * from './getTypeOrmModule';
|
|
5
5
|
export * from './getGraphQlModule';
|
|
6
6
|
export * from './createNestHttpApp';
|
|
7
|
+
export * from './createTestNestApp';
|
|
7
8
|
export * from './ExtraRepository';
|
|
8
9
|
export * from './GqlExceptionFilter';
|
|
9
10
|
export * from './createTestNestHttpApp';
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./createNestApp"), exports);
|
|
|
20
20
|
__exportStar(require("./getTypeOrmModule"), exports);
|
|
21
21
|
__exportStar(require("./getGraphQlModule"), exports);
|
|
22
22
|
__exportStar(require("./createNestHttpApp"), exports);
|
|
23
|
+
__exportStar(require("./createTestNestApp"), exports);
|
|
23
24
|
__exportStar(require("./ExtraRepository"), exports);
|
|
24
25
|
__exportStar(require("./GqlExceptionFilter"), exports);
|
|
25
26
|
__exportStar(require("./createTestNestHttpApp"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,kDAAgC;AAChC,qDAAmC;AACnC,qDAAmC;AACnC,sDAAoC;AACpC,oDAAkC;AAClC,uDAAqC;AACrC,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,kDAAgC;AAChC,qDAAmC;AACnC,qDAAmC;AACnC,sDAAoC;AACpC,sDAAoC;AACpC,oDAAkC;AAClC,uDAAqC;AACrC,0DAAwC"}
|