File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed
generators/app/templates/src Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 1+ const config = {
2+ host : process . env . HOST ?? 'localhost' ,
3+ port : + ( process . env . PORT ?? '9000' ) ,
4+ } ;
5+
6+ export default config ;
Original file line number Diff line number Diff line change @@ -2,25 +2,16 @@ import { MyError } from '@boringcodes/utils/error';
22import errorHandler from '@boringcodes/utils/errorHandler' ;
33import logger from '@boringcodes/utils/logger' ;
44
5+ import config from './config' ;
56import app from './app' ;
67
7- // declare env vars
8- const host =
9- process . env . HOST !== null && process . env . HOST !== undefined
10- ? process . env . HOST
11- : 'localhost' ;
12- const port =
13- process . env . PORT !== null && process . env . PORT !== undefined
14- ? + process . env . PORT
15- : 9000 ;
16-
178// start app
18- app . listen ( port , host , ( err : MyError ) => {
9+ app . listen ( config . port , config . host , ( err : MyError ) => {
1910 if ( err !== null && err !== undefined ) {
2011 throw err ;
2112 }
2213
23- logger . info ( `> App started at http://${ host } :${ port } ` ) ;
14+ logger . info ( `> App started at http://${ config . host } :${ config . port } ` ) ;
2415} ) ;
2516
2617// handle unhandled promise
You can’t perform that action at this time.
0 commit comments