diff --git a/src/config.ts b/src/config.ts index 2d8e94a..31a72fa 100644 --- a/src/config.ts +++ b/src/config.ts @@ -8,14 +8,20 @@ export interface IConfig { dbsslconn: boolean; jwtSecret: string; databaseUrl: string; + dbEntitiesPath: (Function | string)[]; } +const isDevMode = process.env.NODE_ENV == 'development'; + const config: IConfig = { port: +process.env.PORT || 3000, - debugLogging: process.env.NODE_ENV == 'development', - dbsslconn: process.env.NODE_ENV != 'development', + debugLogging: isDevMode, + dbsslconn: !isDevMode, jwtSecret: process.env.JWT_SECRET || 'your-secret-whatever', - databaseUrl: process.env.DATABASE_URL || 'postgres://user:pass@localhost:5432/apidb' + databaseUrl: process.env.DATABASE_URL || 'postgres://user:pass@localhost:5432/apidb', + dbEntitiesPath: [ + ('dist/entity/**/*.js') || (isDevMode && 'src/entity/**/*.ts') + ] }; export { config }; \ No newline at end of file diff --git a/src/server.ts b/src/server.ts index 42d15f9..3e31dd0 100644 --- a/src/server.ts +++ b/src/server.ts @@ -28,9 +28,7 @@ createConnection({ database: connectionOptions.database, synchronize: true, logging: false, - entities: [ - 'dist/entity/**/*.js' - ], + entities: config.dbEntitiesPath, extra: { ssl: config.dbsslconn, // if not development, will use SSL }