File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,24 @@ var JsonGraphqlServer = require('../lib/json-graphql-server.node.min').default;
88var dataFilePath = process . argv . length > 2 ? process . argv [ 2 ] : './data.json' ;
99var data = require ( path . join ( process . cwd ( ) , dataFilePath ) ) ;
1010var PORT = process . env . NODE_PORT || 3000 ;
11+ var HOST = process . env . NODE_HOST || 'localhost' ;
1112var app = express ( ) ;
1213
1314process . argv . forEach ( ( arg , index ) => {
1415 // allow a custom port via CLI
1516 if ( arg === '--p' && process . argv . length > index + 1 ) {
1617 PORT = process . argv [ index + 1 ] ;
1718 }
19+
20+ if ( arg === '--h' && process . argv . length > index + 1 ) {
21+ HOST = process . argv [ index + 1 ] ;
22+ }
1823} ) ;
1924
2025app . use ( cors ( ) ) ;
2126app . use ( '/' , JsonGraphqlServer ( data ) ) ;
22- app . listen ( PORT ) ;
23- var msg = `GraphQL server running with your data at http://localhost :${ PORT } /` ;
27+ app . listen ( PORT , HOST ) ;
28+ var msg = `GraphQL server running with your data at http://${ HOST } :${ PORT } /` ;
2429console . log ( msg ) ; // eslint-disable-line no-console
2530
2631process . on ( 'unhandledRejection' , ( reason , p ) => {
You can’t perform that action at this time.
0 commit comments