Skip to content

Commit

Permalink
fix: config db seed by typeorm-extension (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
khuongln-1346 authored Nov 6, 2024
1 parent 24dc877 commit 3684d1b
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/admin-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"clean": "rm -rf dist",
"dev": "nest start --watch --port 3000",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down
1 change: 1 addition & 0 deletions apps/user-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"clean": "rm -rf dist",
"dev": "nest start --watch --port 3001",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"clean": "rm -rf dist",
"dev": "next dev --turbo --port 4000",
"build": "next build",
"start": "next start",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "nestjs-turbo-monorepo",
"private": true,
"scripts": {
"clean": "turbo clean",
"build": "turbo build",
"dev": "turbo dev",
"test": "turbo test",
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"clean": "rm -rf dist",
"dev": "pnpm build --watch",
"build": "tsc -b -v",
"lint": "eslint \"{src,test}/**/*.ts\""
Expand Down
15 changes: 10 additions & 5 deletions packages/database-typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"clean": "rm -rf dist",
"dev": "pnpm build --watch",
"build": "tsc -b -v",
"lint": "eslint \"{src,test}/**/*.ts\"",
Expand All @@ -13,15 +14,19 @@
"migration:show": "pnpm typeorm migration:show",
"migration:create": "typeorm migration:create",
"migration:generate": "pnpm typeorm migration:generate --pretty",
"db:create": "env-cmd ts-node ./node_modules/typeorm-extension/bin/cli.cjs db:create",
"db:drop": "env-cmd ts-node ./node_modules/typeorm-extension/bin/cli.cjs db:drop",
"seed:run": "env-cmd ts-node ./node_modules/typeorm-extension/bin/cli.cjs seed:run",
"seed:create": "env-cmd ts-node ./node_modules/typeorm-extension/bin/cli.cjs seed:create"
"typeorm-ex": "pnpm build && env-cmd typeorm-extension",
"db:create": "pnpm typeorm-ex db:create",
"db:drop": "pnpm typeorm-ex db:drop",
"seed:run": "pnpm typeorm-ex seed:run",
"seed:create": "pnpm typeorm-ex seed:create"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"./dist/**"
"./dist/**",
"!./dist/factories",
"!./dist/migrations",
"!./dist/seeds"
],
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/database-typeorm/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'reflect-metadata';
import { DataSource, DataSourceOptions } from 'typeorm';
import { SeederOptions } from 'typeorm-extension';

export const AppDataSource = new DataSource({
export const dataSource = new DataSource({
type: process.env.DATABASE_TYPE,
url: process.env.DATABASE_URL,
host: process.env.DATABASE_HOST,
Expand All @@ -16,7 +16,7 @@ export const AppDataSource = new DataSource({
dropSchema: false,
keepConnectionAlive: true,
logging: process.env.NODE_ENV !== 'production',
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
entities: [__dirname + '/dist/**/*.entity{.js}'],
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
migrationsTableName: 'migrations',
poolSize: process.env.DATABASE_MAX_CONNECTIONS
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"./code": "./src/code.tsx"
},
"scripts": {
"clean": "rm -rf dist",
"lint": "eslint \"{src,turbo,test}/**/*.ts\" --fix",
"generate:component": "turbo gen react-component"
},
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"license": "MIT",
"scripts": {
"clean": "rm -rf dist",
"dev": "pnpm build --watch",
"build": "tsc -b -v",
"lint": "eslint \"{src,test}/**/*.ts\""
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"DATABASE_CERT"
],
"tasks": {
"clean": {
"cache": false
},
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
Expand Down

0 comments on commit 3684d1b

Please sign in to comment.