-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
36 lines (28 loc) · 947 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
require('dotenv').load({ silent: true });
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const compression = require('compression');
const config = require('./config');
const healthCheck = require('./healthCheck');
const { notFound, errorMiddleware } = require('./errors');
const app = new express();
app.use(compression());
app.use(bodyParser.json());
app.post(`/logout`, (req, res) => {
res.cookie('express.sess','', { maxAge: -1, httpOnly: true });
return res.redirect('/');
});
app.get('/__gtg', (req, res) => {
res.send('Good to go 👍');
});
app.get('/__health', healthCheck.handle);
// require routes and mount to app
app.use(express.static(`${__dirname}/dist`));
require('./searchRoutes')(app);
require('./indexRoutes')(app);
app.use(notFound);
app.use(errorMiddleware);
app.listen(config.PORT, () => {
console.log(`App listening on port ${config.PORT}`);
});