forked from paralect/koa-api-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
25 lines (19 loc) · 793 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// allows require modules relative to /src folder
// for example: require('lib/mongo/idGenerator')
// all options can be found here: https://gist.github.com/branneman/8048520
require('app-module-path').addPath(__dirname);
global.logger = require('logger');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const { logger } = global;
const config = require('config');
const Koa = require('koa');
process.on('unhandledRejection', (reason, p) => {
logger.error('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
// application specific logging here
});
const app = new Koa();
require('./config/koa')(app);
app.listen(config.port, () => {
logger.warn(`Api server listening on ${config.port}, in ${process.env.NODE_ENV} mode`);
});
module.exports = app;