-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (33 loc) · 987 Bytes
/
index.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
26
27
28
29
30
31
32
33
34
35
36
37
38
require('newrelic');
require('dotenv').config();
const config = require('config');
const express = require('express');
const mongoose = require('mongoose');
const compression = require('compression');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const router = require('./api/router');
const { errorHandler } = require('./api/controllers/error-handler');
const {
MONGO_APPLICATION_URI,
MONGO_APPLICATION_USERNAME,
MONGO_APPLICATION_PASSWORD,
PORT,
} = config;
mongoose.connect(MONGO_APPLICATION_URI, {
keepAlive: true,
useNewUrlParser: true,
user: MONGO_APPLICATION_USERNAME,
pass: MONGO_APPLICATION_PASSWORD
})
.catch(e => console.log(e));
const app = express();
app.use(bodyParser.json());
app.use(compression());
app.use(morgan('tiny'));
app.use(express.static('public'));
app.use(router());
app.use(errorHandler());
app.listen(PORT, () => {
console.log(`Gab.ly application up and running on port ${PORT}`)
});