Browse Source

Ormconfig

Nicolas Meienberger 3 năm trước cách đây
mục cha
commit
774ce22dcd

+ 0 - 10
packages/system-api/ormconfig.json

@@ -1,10 +0,0 @@
-{
-  "type": "postgres",
-  "host": "localhost",
-  "port": 5432,
-  "username": "postgres",
-  "password": "postgres",
-  "database": "test-db",
-  "entities": ["src/modules/**/*.entity.ts"],
-  "migrations": ["src/config/migrations/*.ts"]
-}

+ 12 - 0
packages/system-api/ormconfig.ts

@@ -0,0 +1,12 @@
+import { DataSource } from 'typeorm';
+
+export default new DataSource({
+  type: 'postgres',
+  host: 'localhost',
+  port: 5432,
+  username: 'postgres',
+  password: 'postgres',
+  database: 'test-db',
+  entities: ['src/modules/**/*.entity.ts'],
+  migrations: ['src/config/migrations/*.ts'],
+});

+ 6 - 2
packages/system-api/package.json

@@ -3,7 +3,7 @@
   "version": "0.3.1",
   "description": "",
   "exports": "./dist/server.js",
-  "type": "module",
+  "type": "commonjs",
   "engines": {
     "node": ">=14.16"
   },
@@ -17,7 +17,8 @@
     "build:watch": "esbuild --bundle src/server.ts --outdir=dist --allow-overwrite --sourcemap --platform=node --external:./node_modules/* --format=esm --watch",
     "start:dev": "NODE_ENV=development nodemon --trace-deprecation --trace-warnings --watch dist dist/server.js",
     "dev": "concurrently \"npm run build:watch\" \"npm run start:dev\"",
-    "start": "NODE_ENV=production node dist/server.js"
+    "start": "NODE_ENV=production node dist/server.js",
+    "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js -d ormconfig.ts"
   },
   "author": "",
   "license": "ISC",
@@ -62,6 +63,7 @@
     "@types/jest": "^27.5.0",
     "@types/jsonwebtoken": "^8.5.8",
     "@types/mock-fs": "^4.13.1",
+    "@types/node": "17.0.31",
     "@types/pg": "^8.6.5",
     "@types/session-file-store": "^1.2.2",
     "@types/tcp-port-used": "^1.0.1",
@@ -80,6 +82,8 @@
     "prettier": "2.6.2",
     "rimraf": "^3.0.2",
     "ts-jest": "^28.0.2",
+    "ts-node": "^10.8.2",
+    "tsconfig-paths": "^4.0.0",
     "typescript": "4.6.4"
   }
 }

+ 1 - 1
packages/system-api/tsconfig.json

@@ -17,6 +17,6 @@
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true
   },
-  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "jest.config.cjs"],
+  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "jest.config.cjs", "ormconfig.js"],
   "exclude": ["node_modules"]
 }

+ 11 - 1
pnpm-lock.yaml

@@ -182,6 +182,7 @@ importers:
       tcp-port-used: ^1.0.2
       ts-jest: ^28.0.2
       ts-node: ^10.8.2
+      tsconfig-paths: ^4.0.0
       type-graphql: ^1.1.1
       typeorm: ^0.3.6
       typescript: 4.6.4
@@ -246,6 +247,7 @@ importers:
       rimraf: 3.0.2
       ts-jest: 28.0.2_k4xvjffwcpckmnpd5fcvxvnd24
       ts-node: 10.8.2_l47be6km5p57gglrggidw5gsgm
+      tsconfig-paths: 4.0.0
       typescript: 4.6.4
 
 packages:
@@ -10926,7 +10928,7 @@ packages:
       ansi-regex: 5.0.1
 
   /strip-bom/3.0.0:
-    resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=}
+    resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}
     engines: {node: '>=4'}
     dev: true
 
@@ -11362,6 +11364,14 @@ packages:
       strip-bom: 3.0.0
     dev: true
 
+  /tsconfig-paths/4.0.0:
+    resolution: {integrity: sha512-SLBg2GBKlR6bVtMgJJlud/o3waplKtL7skmLkExomIiaAtLGtVsoXIqP3SYdjbcH9lq/KVv7pMZeCBpLYOit6Q==}
+    dependencies:
+      json5: 2.2.1
+      minimist: 1.2.6
+      strip-bom: 3.0.0
+    dev: true
+
   /tslib/1.14.1:
     resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}