@@ -8,7 +8,6 @@ import rest from 'feathers-rest';
88import socketio from 'feathers-socketio' ;
99import isPromise from 'is-promise' ;
1010import PrettyError from 'pretty-error' ;
11- import publicConfig from '../src/config' ;
1211import config from './config' ;
1312import middleware from './middleware' ;
1413import services from './services' ;
@@ -35,16 +34,15 @@ app.set('config', config)
3534
3635const actionsHandler = ( req , res , next ) => {
3736 const splittedUrlPath = req . url . split ( '?' ) [ 0 ] . split ( '/' ) . slice ( 1 ) ;
38-
3937 const { action, params } = mapUrl ( actions , splittedUrlPath ) ;
4038
39+ req . app = app ;
40+
4141 const catchError = error => {
4242 console . error ( 'API ERROR:' , pretty . render ( error ) ) ;
4343 res . status ( error . status || 500 ) . json ( error ) ;
4444 } ;
4545
46- req . app = app ;
47-
4846 if ( action ) {
4947 try {
5048 const handle = action ( req , params ) ;
@@ -79,13 +77,13 @@ app.configure(hooks())
7977 . configure ( services )
8078 . configure ( middleware ) ;
8179
82- if ( publicConfig . apiPort ) {
83- app . listen ( publicConfig . apiPort , err => {
80+ if ( process . env . APIPORT ) {
81+ app . listen ( process . env . APIPORT , err => {
8482 if ( err ) {
8583 console . error ( err ) ;
8684 }
87- console . info ( '----\n==> 🌎 API is running on port %s' , publicConfig . apiPort ) ;
88- console . info ( '==> 💻 Send requests to http://%s :%s' , publicConfig . apiHost , publicConfig . apiPort ) ;
85+ console . info ( '----\n==> 🌎 API is running on port %s' , process . env . APIPORT ) ;
86+ console . info ( '==> 💻 Send requests to http://localhost :%s' , process . env . APIPORT ) ;
8987 } ) ;
9088} else {
9189 console . error ( '==> ERROR: No APIPORT environment variable has been specified' ) ;
0 commit comments