@nmxjs/app 1.0.46 → 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/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"}
|