Skip to content

Commit 3c62247

Browse files
authored
Merge pull request #47 from mberneti/master
fixed entities path bug of the connection in the dev mode
2 parents 96c3842 + 1d7b204 commit 3c62247

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/config.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ export interface IConfig {
88
dbsslconn: boolean;
99
jwtSecret: string;
1010
databaseUrl: string;
11+
dbEntitiesPath: (Function | string)[];
1112
}
1213

14+
const isDevMode = process.env.NODE_ENV == 'development';
15+
1316
const config: IConfig = {
1417
port: +process.env.PORT || 3000,
15-
debugLogging: process.env.NODE_ENV == 'development',
16-
dbsslconn: process.env.NODE_ENV != 'development',
18+
debugLogging: isDevMode,
19+
dbsslconn: !isDevMode,
1720
jwtSecret: process.env.JWT_SECRET || 'your-secret-whatever',
18-
databaseUrl: process.env.DATABASE_URL || 'postgres://user:pass@localhost:5432/apidb'
21+
databaseUrl: process.env.DATABASE_URL || 'postgres://user:pass@localhost:5432/apidb',
22+
dbEntitiesPath: [
23+
('dist/entity/**/*.js') || (isDevMode && 'src/entity/**/*.ts')
24+
]
1925
};
2026

2127
export { config };

src/server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ createConnection({
2828
database: connectionOptions.database,
2929
synchronize: true,
3030
logging: false,
31-
entities: [
32-
'dist/entity/**/*.js'
33-
],
31+
entities: config.dbEntitiesPath,
3432
extra: {
3533
ssl: config.dbsslconn, // if not development, will use SSL
3634
}

0 commit comments

Comments
 (0)