Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

require('./app-bootstrap')

const bodyParser = require('body-parser')
const config = require('config')
const cors = require('cors')
const express = require('express')
const bodyParser = require('body-parser')
const _ = require('lodash')
const cors = require('cors')
const logger = require('./src/common/logger')
const HttpStatus = require('http-status-codes')
const morgan = require('morgan')
const swaggerUi = require('swagger-ui-express')
const YAML = require('yamljs')
const { closeDB } = require('./src/common/helper')

const helper = require('./src/common/helper')
const logger = require('./src/common/logger')

const swaggerDocument = YAML.load('./docs/swagger.yml')
// setup express app
Expand Down Expand Up @@ -69,10 +70,11 @@ app.use((err, req, res, next) => {

const server = app.listen(app.get('port'), () => {
logger.info(`Express server listening on port ${app.get('port')}`)
helper.initiateCache()
})

server.on('close', async (error) => {
await closeDB()
await helper.closeDB()
logger.info('server closed')
process.exit(error ? 1 : 0)
})
Loading