-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (33 loc) · 784 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
const {
express,
config,
bodyParser,
expressValidator,
rootRoutes,
customSanitizers,
customValidators,
compression
} = require('sp-load'),
app = express(),
port = config.defultPort;
app.use(compression());
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(expressValidator({
customSanitizers: customSanitizers,
customValidators: customValidators
}));
app.use(rootRoutes);
app.use(function (req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.json({
message: err.message || 'Something failed!'
});
});
app.listen(port);