-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
43 lines (30 loc) · 951 Bytes
/
app.js
File metadata and controls
43 lines (30 loc) · 951 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
33
34
35
36
37
38
39
40
41
42
43
const path = require('path');
const express = require('express');
const logger = require('morgan');
const helmet = require('helmet');
const indexRouter = require('./routes/index');
// const testRouter = require('./routes/test');
const app = express();
app.use(helmet.crossOriginResourcePolicy());
app.use(helmet.hidePoweredBy());
app.use((req, res, next) => {
res.set('Permissions-Policy', 'geolocation=(), microphone=()');
next();
});
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use('/static', express.static('public'));
app.use('/', indexRouter);
// app.use('/', testRouter);
app.use((req, res, next) => {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use((err, req, res, next) => {
res.status(err.status ?? 500).send(err.message);
});
module.exports = app;