forked from project-sunbird/sunbird-report-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (28 loc) · 943 Bytes
/
app.js
File metadata and controls
32 lines (28 loc) · 943 Bytes
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
26
27
28
29
30
31
32
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
var debug = require('debug')('report-service:server');
const mountRoutes = require('./routes');
const app = express();
const { sequelize } = require('./models');
const { printEnvVariablesStatus } = require('./helpers/envHelpers');
app.use(logger('dev'));
app.use(express.json({ limit: '1mb' }));
app.use(express.urlencoded({ extended: false, limit: '1mb' }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
//connect to the database and mount routes
(async () => {
try {
printEnvVariablesStatus();
await sequelize.authenticate();
// await sequelize.sync();
debug('Connected to the database');
mountRoutes(app);
} catch (error) {
debug('Unable to connect to database', error);
process.exit(1);
}
})();
module.exports = app;