-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
46 lines (33 loc) · 926 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
require('dotenv').config();
const bodyParser = require('body-parser');
const path = require('path');
const http = require('http');
const morgan = require('morgan');
const helmet = require('helmet');
const compression = require('compression');
const express = require('express');
const app = express();
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, '/public')));
// compressing api response
app.use(compression());
// body-parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// logger
app.use(morgan('dev'));
// security config
app.use(helmet());
// routes
app.use(require('./routes/webhook'));
app.get('/', (req, res) => {
res.render('index');
});
// port initialized
const port = process.env.PORT || 8080;
// server setup
const server = http.createServer(app)
server.listen(port, () => {
console.log(`Running on ${port}`);
});