-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
38 lines (33 loc) · 1.11 KB
/
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
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const middleware = require('./middleware');
const indexRouter = require('./routes/index');
const registerRouter = require('./routes/register');
const sendRouter = require('./routes/send');
const cancelRouter = require('./routes/cancel_reminders');
const adminRouter = require('./routes/admin');
const healthRouter = require('./routes/health');
const app = express();
// Setup middleware
app.use(middleware.create_env);
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/register', registerRouter);
app.use('/send', sendRouter);
app.use('/cancel-reminders', cancelRouter);
app.use('/super-duper-only', adminRouter);
app.use('/health', healthRouter);
app.use(function(err, req, res, next) {
if (res.headersSent) {
return next(err);
}
console.error(err)
return res.json(err);
});
module.exports = app;