@zola_do/typeorm 0.1.9
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/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/typeorm-config-helper.d.ts +12 -0
- package/dist/typeorm-config-helper.js +51 -0
- package/dist/typeorm-config-helper.js.map +1 -0
- package/dist/typeorm.service.d.ts +5 -0
- package/dist/typeorm.service.js +21 -0
- package/dist/typeorm.service.js.map +1 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./typeorm-config-helper"), exports);
|
|
18
|
+
__exportStar(require("./typeorm.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SeederOptions } from 'typeorm-extension';
|
|
2
|
+
import { DataSourceOptions } from 'typeorm';
|
|
3
|
+
export declare const TypeOrmConfigHelper: {
|
|
4
|
+
DATABASE_HOST: string;
|
|
5
|
+
DATABASE_PORT: string;
|
|
6
|
+
DATABASE_NAME: string;
|
|
7
|
+
DATABASE_USER: string;
|
|
8
|
+
DATABASE_PASSWORD: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const dataSourceOptions: DataSourceOptions & SeederOptions;
|
|
11
|
+
declare const dataSources: any;
|
|
12
|
+
export default dataSources;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b, _c, _d;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.dataSourceOptions = exports.TypeOrmConfigHelper = void 0;
|
|
5
|
+
const dotenv = require("dotenv");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
dotenv.config({ path: '.env' });
|
|
8
|
+
const validateDatabaseConfig = () => {
|
|
9
|
+
if (!process.env.DATABASE_PASSWORD) {
|
|
10
|
+
throw new Error('DATABASE_PASSWORD environment variable is required. Do not use default passwords in production.');
|
|
11
|
+
}
|
|
12
|
+
if (!process.env.DATABASE_NAME && !process.env.APP_NAME) {
|
|
13
|
+
throw new Error('Either DATABASE_NAME or APP_NAME environment variable is required.');
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
if (process.env.NODE_ENV === 'production') {
|
|
17
|
+
validateDatabaseConfig();
|
|
18
|
+
}
|
|
19
|
+
exports.TypeOrmConfigHelper = {
|
|
20
|
+
DATABASE_HOST: (_a = process.env.DATABASE_HOST) !== null && _a !== void 0 ? _a : 'localhost',
|
|
21
|
+
DATABASE_PORT: (_b = process.env.DATABASE_PORT) !== null && _b !== void 0 ? _b : '5432',
|
|
22
|
+
DATABASE_NAME: (_c = process.env.DATABASE_NAME) !== null && _c !== void 0 ? _c : process.env.APP_NAME,
|
|
23
|
+
DATABASE_USER: (_d = process.env.DATABASE_USER) !== null && _d !== void 0 ? _d : 'postgres',
|
|
24
|
+
DATABASE_PASSWORD: process.env.DATABASE_PASSWORD,
|
|
25
|
+
};
|
|
26
|
+
const pathPrefix = process.env.NODE_ENV === 'production'
|
|
27
|
+
? `apps/server/${process.env.APP_NAME}/`
|
|
28
|
+
: '';
|
|
29
|
+
exports.dataSourceOptions = {
|
|
30
|
+
type: 'postgres',
|
|
31
|
+
host: exports.TypeOrmConfigHelper.DATABASE_HOST,
|
|
32
|
+
port: Number(exports.TypeOrmConfigHelper.DATABASE_PORT),
|
|
33
|
+
database: exports.TypeOrmConfigHelper.DATABASE_NAME,
|
|
34
|
+
username: exports.TypeOrmConfigHelper.DATABASE_USER,
|
|
35
|
+
password: exports.TypeOrmConfigHelper.DATABASE_PASSWORD,
|
|
36
|
+
entities: [
|
|
37
|
+
`${pathPrefix}dist/**/*.entity.{ts,js}`,
|
|
38
|
+
`${pathPrefix}dist/**/*.view.{ts,js}`
|
|
39
|
+
],
|
|
40
|
+
migrations: [`${pathPrefix}dist/migrations/*.{ts,js}`],
|
|
41
|
+
migrationsRun: true,
|
|
42
|
+
seeds: [`${pathPrefix}dist/modules/seeders/**.seeder.{ts,js}`],
|
|
43
|
+
migrationsTableName: 'typeorm_migrations',
|
|
44
|
+
logger: 'advanced-console',
|
|
45
|
+
logging: 'all',
|
|
46
|
+
synchronize: false,
|
|
47
|
+
autoLoadEntities: true,
|
|
48
|
+
};
|
|
49
|
+
const dataSources = new typeorm_1.DataSource(exports.dataSourceOptions);
|
|
50
|
+
exports.default = dataSources;
|
|
51
|
+
//# sourceMappingURL=typeorm-config-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-config-helper.js","sourceRoot":"","sources":["../src/typeorm-config-helper.ts"],"names":[],"mappings":";;;;AAAA,iCAAiC;AAEjC,qCAAwD;A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E,2BAAmB,CAAC,aAAa;IAC3C,QAAQ,EAAE,2BAAmB,CAAC,aAAa;IAC3C,QAAQ,EAAE,2BAAmB,CAAC,iBAAiB;IAC/C,QAAQ,EAAE;QACR,GAAG,UAAU,0BAA0B;QACvC,GAAG,UAAU,wBAAwB;KACtC;IACD,UAAU,EAAE,CAAC,GAAG,UAAU,2BAA2B,CAAC;IACtD,aAAa,EAAE,IAAI;IACnB,KAAK,EAAE,CAAC,GAAG,UAAU,wCAAwC,CAAC;IAC9D,mBAAmB,EAAE,oBAAoB;IACzC,MAAM,EAAE,kBAAkB;IAC1B,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,IAAI;CACc,CAAC;AAEvC,MAAM,WAAW,GAAG,IAAI,oBAAU,CAAC,yBAAiB,CAAC,CAAC;AAEtD,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TypeOrmOptionsFactory, TypeOrmModuleOptions } from '@nestjs/typeorm';
|
|
2
|
+
import { SeederOptions } from 'typeorm-extension';
|
|
3
|
+
export declare class TypeOrmConfigService implements TypeOrmOptionsFactory {
|
|
4
|
+
createTypeOrmOptions(): TypeOrmModuleOptions & SeederOptions;
|
|
5
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TypeOrmConfigService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_config_helper_1 = require("./typeorm-config-helper");
|
|
12
|
+
let TypeOrmConfigService = class TypeOrmConfigService {
|
|
13
|
+
createTypeOrmOptions() {
|
|
14
|
+
return typeorm_config_helper_1.dataSourceOptions;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.TypeOrmConfigService = TypeOrmConfigService;
|
|
18
|
+
exports.TypeOrmConfigService = TypeOrmConfigService = __decorate([
|
|
19
|
+
(0, common_1.Injectable)()
|
|
20
|
+
], TypeOrmConfigService);
|
|
21
|
+
//# sourceMappingURL=typeorm.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm.service.js","sourceRoot":"","sources":["../src/typeorm.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAE5C,mEAA4D;AAIrD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACxB,oBAAoB;QACzB,OAAO,yCAAiB,CAAC;IAC3B,CAAC;CACF,CAAA;AAJY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CAIhC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zola_do/typeorm",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "TypeORM configuration for NestJS",
|
|
5
|
+
"author": "zolaDO",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", "README.md"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rimraf dist && tsc",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
25
|
+
"@nestjs/typeorm": "^10.0.0 || ^11.0.0",
|
|
26
|
+
"typeorm": "^0.3.0",
|
|
27
|
+
"typeorm-extension": "^3.7.1"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"dotenv": "^17.2.3"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"rimraf": "^6.1.0",
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
}
|
|
36
|
+
}
|