Bring in the common function for starting all feathers applications

This commit is contained in:
R Tyler Croy 2019-06-25 19:17:02 -07:00
parent ab578dd8b8
commit a8f4c889fe
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
3 changed files with 32 additions and 1 deletions

29
lib/src/server.ts Normal file
View File

@ -0,0 +1,29 @@
/**
* This module acts as the simple wrapper for serving any feathers application
* in the project
*/
import logger from '@otto/logger';
import { Application } from '@feathersjs/express';
/**
* The serveApp function expects a Feathers application which it can start
* serving on its configured port
*
* This method is *asynchronous* and will not return a success or fail
*
* @param app An instantiated feathers application
*/
export function serveApp(app: Application) {
const port: Number = app.get('port');
const server: any = app.listen(port);
process.on('unhandledRejection', (reason, p) =>
logger.error('Unhandled Rejection at: Promise ', p, reason)
);
server.on('listening', () =>
logger.info('Feathers application started on http://%s:%d', app.get('host'), port)
);
}

View File

@ -1,4 +1,6 @@
require('module-alias/register');
import logger from '@otto/logger';
import { serveApp } from '@otto/server'
logger.info('Starting orchestrator');

View File

@ -13,7 +13,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"noUnusedLocals": false,
"strictNullChecks": true,
"skipLibCheck": true,