@slickteam/nestjs-pg-typeorm 2.1.4 → 2.1.6

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const child_process_1 = require("child_process");
5
+ const path_1 = require("path");
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+ const restArgs = args.slice(1).join(' ');
9
+ const dataSourcePath = (0, path_1.resolve)(__dirname, 'database-config.js');
10
+ const commands = {
11
+ create: `typeorm migration:create ${restArgs}`,
12
+ generate: `typeorm migration:generate -d ${dataSourcePath} ${restArgs}`,
13
+ run: `typeorm migration:run -d ${dataSourcePath} ${restArgs}`,
14
+ revert: `typeorm migration:revert -d ${dataSourcePath} ${restArgs}`,
15
+ show: `typeorm migration:show -d ${dataSourcePath} ${restArgs}`,
16
+ drop: `typeorm schema:drop -d ${dataSourcePath} ${restArgs}`,
17
+ };
18
+ function printHelp() {
19
+ console.log(`
20
+ slick-migration - TypeORM migration CLI for @slickteam/nestjs-pg-typeorm
21
+
22
+ Usage: slick-migration <command> [options]
23
+
24
+ Commands:
25
+ create <path> Create a new empty migration file
26
+ generate <path> Generate a migration from schema changes
27
+ run Run pending migrations
28
+ revert Revert the last executed migration
29
+ show Show all migrations and their status
30
+ drop Drop the database schema
31
+
32
+ Examples:
33
+ slick-migration create src/migrations/CreateUserTable
34
+ slick-migration generate src/migrations/AddEmailColumn
35
+ slick-migration run
36
+ slick-migration revert
37
+ slick-migration show
38
+ `);
39
+ }
40
+ if (!command || command === '--help' || command === '-h') {
41
+ printHelp();
42
+ process.exit(0);
43
+ }
44
+ if (!commands[command]) {
45
+ console.error(`Unknown command: ${command}\n`);
46
+ printHelp();
47
+ process.exit(1);
48
+ }
49
+ try {
50
+ (0, child_process_1.execSync)(commands[command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AC/C,SAAS,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC;IACH,IAAA,wBAAQ,EAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACpD,CAAC;AAAC,MAAM,CAAC;IACP,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { DataSource, DataSourceOptions } from 'typeorm';
2
+ export declare const databaseSettings: DataSourceOptions;
3
+ declare const _default: DataSource;
4
+ export default _default;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.databaseSettings = void 0;
4
+ const dotenv_1 = require("dotenv");
5
+ const typeorm_1 = require("typeorm");
6
+ (0, dotenv_1.config)({ quiet: true });
7
+ function postgresLogger() {
8
+ const loggerType = process.env.POSTGRESQL_LOGGER;
9
+ return loggerType === 'advanced-console' || loggerType === 'simple-console' || loggerType === 'file' || loggerType === 'debug'
10
+ ? loggerType
11
+ : undefined;
12
+ }
13
+ exports.databaseSettings = {
14
+ type: 'postgres',
15
+ host: process.env.POSTGRESQL_ADDON_HOST,
16
+ port: Number(process.env.POSTGRESQL_ADDON_PORT),
17
+ username: process.env.POSTGRESQL_ADDON_USER,
18
+ password: process.env.POSTGRESQL_ADDON_PASSWORD,
19
+ database: process.env.POSTGRESQL_ADDON_DB,
20
+ synchronize: process.env.POSTGRESQL_SYNCHRONIZE === 'true',
21
+ logger: postgresLogger(),
22
+ logging: process.env.POSTGRESQL_LOGGING === 'true',
23
+ poolSize: process.env.POSTGRESQL_MAX_POOL_SIZE ? Number(process.env.POSTGRESQL_MAX_POOL_SIZE) : undefined,
24
+ entities: process.env.POSTGRESQL_ENTITY_PATH?.split(',') ?? [
25
+ 'dist/**/*entity.js',
26
+ 'dist/**/*Entity.js',
27
+ 'dist/**/**/*entity.js',
28
+ 'dist/**/**/*Entity.js',
29
+ ],
30
+ migrations: [process.env.POSTGRESQL_MIGRATION_PATH ?? 'dist/migration/*.js'],
31
+ };
32
+ exports.default = new typeorm_1.DataSource(exports.databaseSettings);
33
+ //# sourceMappingURL=database-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-config.js","sourceRoot":"","sources":["../../src/database-config.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,qCAAwD;AAExD,IAAA,eAAM,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAExB,SAAS,cAAc;IACrB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACjD,OAAO,UAAU,KAAK,kBAAkB,IAAI,UAAU,KAAK,gBAAgB,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,OAAO;QAC5H,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAEY,QAAA,gBAAgB,GAAsB;IACjD,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC/C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;IAC/C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,MAAM;IAC1D,MAAM,EAAE,cAAc,EAAE;IACxB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM;IAClD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,SAAS;IACzG,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI;QAC1D,oBAAoB;QACpB,oBAAoB;QACpB,uBAAuB;QACvB,uBAAuB;KACxB;IACD,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,qBAAqB,CAAC;CAC7E,CAAC;AAEF,kBAAe,IAAI,oBAAU,CAAC,wBAAgB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { InjectDataSource, InjectEntityManager, InjectRepository, TypeOrmModule, TypeOrmModuleAsyncOptions, TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
2
+ export * from 'typeorm';
3
+ declare class DatabaseModule {
4
+ }
5
+ export { DatabaseModule, TypeOrmModule, TypeOrmModuleAsyncOptions, TypeOrmModuleOptions, TypeOrmOptionsFactory, InjectDataSource, InjectEntityManager, InjectRepository, };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
18
+ };
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.InjectRepository = exports.InjectEntityManager = exports.InjectDataSource = exports.TypeOrmModule = exports.DatabaseModule = void 0;
24
+ const common_1 = require("@nestjs/common");
25
+ const typeorm_1 = require("@nestjs/typeorm");
26
+ Object.defineProperty(exports, "InjectDataSource", { enumerable: true, get: function () { return typeorm_1.InjectDataSource; } });
27
+ Object.defineProperty(exports, "InjectEntityManager", { enumerable: true, get: function () { return typeorm_1.InjectEntityManager; } });
28
+ Object.defineProperty(exports, "InjectRepository", { enumerable: true, get: function () { return typeorm_1.InjectRepository; } });
29
+ Object.defineProperty(exports, "TypeOrmModule", { enumerable: true, get: function () { return typeorm_1.TypeOrmModule; } });
30
+ const database_config_1 = require("./database-config");
31
+ __exportStar(require("typeorm"), exports);
32
+ let DatabaseModule = class DatabaseModule {
33
+ };
34
+ exports.DatabaseModule = DatabaseModule;
35
+ exports.DatabaseModule = DatabaseModule = __decorate([
36
+ (0, common_1.Module)({
37
+ imports: [
38
+ typeorm_1.TypeOrmModule.forRootAsync({
39
+ useFactory: () => database_config_1.databaseSettings,
40
+ }),
41
+ ],
42
+ exports: [typeorm_1.TypeOrmModule],
43
+ })
44
+ ], DatabaseModule);
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAQyB;AAsBvB,iGA7BA,0BAAgB,OA6BA;AAChB,oGA7BA,6BAAmB,OA6BA;AACnB,iGA7BA,0BAAgB,OA6BA;AANhB,8FAtBA,uBAAa,OAsBA;AAhBf,uDAAqD;AAErD,0CAAwB;AAUxB,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAGrB,wCAAc;yBAHV,cAAc;IARnB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,YAAY,CAAC;gBACzB,UAAU,EAAE,GAAG,EAAE,CAAC,kCAAgB;aACnC,CAAC;SACH;QACD,OAAO,EAAE,CAAC,uBAAa,CAAC;KACzB,CAAC;GACI,cAAc,CAAG"}