Bring in the common function for starting all feathers applications
This commit is contained in:
parent
ab578dd8b8
commit
a8f4c889fe
|
@ -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)
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
require('module-alias/register');
|
require('module-alias/register');
|
||||||
|
|
||||||
import logger from '@otto/logger';
|
import logger from '@otto/logger';
|
||||||
|
import { serveApp } from '@otto/server'
|
||||||
|
|
||||||
logger.info('Starting orchestrator');
|
logger.info('Starting orchestrator');
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": false,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue