9
9
*/
10
10
'use strict' ;
11
11
const express = require ( 'express' ) ;
12
- const logger = require ( 'morgan' ) ;
12
+ // const logger = require('morgan');
13
13
const cookieParser = require ( 'cookie-parser' ) ;
14
14
const bodyParser = require ( 'body-parser' ) ;
15
15
const healthcheck = require ( 'topcoder-healthcheck-dropin' ) ;
16
+ const logger = require ( './utils/logger' ) ;
16
17
17
18
/**
18
19
* Method to check the service status
@@ -29,7 +30,7 @@ const webhooks = require('./routes/webhooks');
29
30
30
31
const app = express ( ) ;
31
32
32
- app . use ( logger ( 'dev' ) ) ;
33
+ // app.use(logger('dev'));
33
34
app . use ( bodyParser . json ( {
34
35
verify : ( req , res , buf ) => {
35
36
req . rawBody = buf . toString ( ) ;
@@ -49,7 +50,7 @@ app.use((req, res, next) => {
49
50
next ( err ) ;
50
51
} ) ;
51
52
52
- // error handler
53
+ // // error handler
53
54
app . use ( ( err , req , res , next ) => { // eslint-disable-line no-unused-vars
54
55
console . log ( err ) ;
55
56
res . status ( err . status || 500 ) ; // eslint-disable-line no-magic-numbers
@@ -60,16 +61,20 @@ app.use((err, req, res, next) => { // eslint-disable-line no-unused-vars
60
61
} ) ;
61
62
62
63
process . on ( 'uncaughtException' , ( err ) => {
64
+ // logger.error('Exception: ', err);
63
65
// Check if error related to Dynamodb conn
64
66
if ( err . code === 'NetworkingError' && err . region ) {
65
67
logger . error ( 'DynamoDB connection failed.' ) ;
66
68
}
67
69
logger . logFullError ( err , 'system' ) ;
70
+ // console.log(err);
68
71
} ) ;
69
72
70
73
// handle and log unhanled rejection
71
74
process . on ( 'unhandledRejection' , ( err ) => {
75
+ // logger.error('Rejection: ', err);
72
76
logger . logFullError ( err , 'system' ) ;
77
+ // console.log(err);
73
78
} ) ;
74
79
75
80
module . exports = app ;
0 commit comments