@@ -2,7 +2,7 @@ import * as dotenv from 'dotenv';
22import * as path from 'path' ;
33
44import * as pkg from '../package.json' ;
5- import { getOsEnv , normalizePort , toBool , toNumber } from './lib/env' ;
5+ import { getOsEnv , getOsEnvArray , normalizePort , toBool , toNumber } from './lib/env' ;
66
77/**
88 * Load .env file or for tests the .env.test file.
@@ -27,15 +27,39 @@ export const env = {
2727 port : normalizePort ( process . env . PORT || getOsEnv ( 'APP_PORT' ) ) ,
2828 banner : toBool ( getOsEnv ( 'APP_BANNER' ) ) ,
2929 dirs : {
30- migrations : [ path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'database/migrations/**/*.ts' ) ) ] ,
31- migrationsDir : path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'database/migrations' ) ) ,
32- entities : [ path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'api/models/**/*{.js,.ts}' ) ) ] ,
33- subscribers : [ path . join ( __dirname , 'api/subscribers/**/*Subscriber{.js,.ts}' ) ] ,
34- controllers : [ path . join ( __dirname , 'api/controllers/**/*Controller{.js,.ts}' ) ] ,
35- middlewares : [ path . join ( __dirname , 'api/middlewares/**/*Middleware{.js,.ts}' ) ] ,
36- interceptors : [ path . join ( __dirname , 'api/interceptors/**/*Interceptor{.js,.ts}' ) ] ,
37- queries : [ path . join ( __dirname , 'api/queries/**/*Query{.js,.ts}' ) ] ,
38- mutations : [ path . join ( __dirname , 'api/mutations/**/*Mutation{.js,.ts}' ) ] ,
30+ migrations : (
31+ getOsEnvArray ( 'TYPEORM_MIGRATIONS' ) ||
32+ [ path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'database/migrations/**/*.ts' ) ) ]
33+ ) as string [ ] ,
34+ migrationsDir : getOsEnv ( 'TYPEORM_MIGRATIONS_DIR' ) || path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'database/migrations' ) ) ,
35+ entities : (
36+ getOsEnvArray ( 'TYPEORM_ENTITIES' ) ||
37+ [ path . relative ( path . join ( process . cwd ( ) ) , path . join ( __dirname , 'api/models/**/*{.js,.ts}' ) ) ]
38+ ) as string [ ] ,
39+ subscribers : (
40+ getOsEnvArray ( 'TYPEORM_SUBSCRIBERS' ) ||
41+ [ path . join ( __dirname , 'api/subscribers/**/*Subscriber{.js,.ts}' ) ]
42+ ) as string [ ] ,
43+ controllers : (
44+ getOsEnvArray ( 'CONTROLLERS' ) ||
45+ [ path . join ( __dirname , 'api/controllers/**/*Controller{.js,.ts}' ) ]
46+ ) as string [ ] ,
47+ middlewares : (
48+ getOsEnvArray ( 'MIDDLEWARES' ) ||
49+ [ path . join ( __dirname , 'api/middlewares/**/*Middleware{.js,.ts}' ) ]
50+ ) as string [ ] ,
51+ interceptors : (
52+ getOsEnvArray ( 'INTERCEPTORS' ) ||
53+ [ path . join ( __dirname , 'api/interceptors/**/*Interceptor{.js,.ts}' ) ]
54+ ) as string [ ] ,
55+ queries : (
56+ getOsEnvArray ( 'QUERIES' ) ||
57+ [ path . join ( __dirname , 'api/queries/**/*Query{.js,.ts}' ) ]
58+ ) as string [ ] ,
59+ mutations : (
60+ getOsEnvArray ( 'MUTATIONS' ) ||
61+ [ path . join ( __dirname , 'api/mutations/**/*Mutation{.js,.ts}' ) ]
62+ ) as string [ ] ,
3963 } ,
4064 } ,
4165 log : {
@@ -47,14 +71,14 @@ export const env = {
4771 route : getOsEnv ( 'AUTH_ROUTE' ) ,
4872 } ,
4973 db : {
50- type : getOsEnv ( 'DB_TYPE ' ) ,
51- host : getOsEnv ( 'DB_HOST ' ) ,
52- port : toNumber ( getOsEnv ( 'DB_PORT ' ) ) ,
53- username : getOsEnv ( 'DB_USERNAME ' ) ,
54- password : getOsEnv ( 'DB_PASSWORD ' ) ,
55- database : getOsEnv ( 'DB_DATABASE ' ) ,
56- synchronize : toBool ( getOsEnv ( 'DB_SYNCHRONIZE ' ) ) ,
57- logging : toBool ( getOsEnv ( 'DB_LOGGING ' ) ) ,
74+ type : getOsEnv ( 'TYPEORM_CONNECTION ' ) ,
75+ host : getOsEnv ( 'TYPEORM_HOST ' ) ,
76+ port : toNumber ( getOsEnv ( 'TYPEORM_PORT ' ) ) ,
77+ username : getOsEnv ( 'TYPEORM_USERNAME ' ) ,
78+ password : getOsEnv ( 'TYPEORM_PASSWORD ' ) ,
79+ database : getOsEnv ( 'TYPEORM_DATABASE ' ) ,
80+ synchronize : toBool ( getOsEnv ( 'TYPEORM_SYNCHRONIZE ' ) ) ,
81+ logging : toBool ( getOsEnv ( 'TYPEORM_LOGGING ' ) ) ,
5882 } ,
5983 graphql : {
6084 enabled : toBool ( getOsEnv ( 'GRAPHQL_ENABLED' ) ) ,
0 commit comments