-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (30 loc) · 792 Bytes
/
app.js
File metadata and controls
36 lines (30 loc) · 792 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
var express = require('express');
var app = express();
var server = require('http').Server(app);
server.listen(3000, function() {
console.log("Server its ready");
});
var index = require('./routes/index');
var clients = require('./routes/clients');
var policies = require('./routes/policies');
app.use('/', index);
app.use('/client', clients);
app.use('/policy', policies);
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
if (err.name === 'UnauthorizedError') {
err.status = 401;
}
next(err);
});
app.use(function (err, req, res, next) {
res.status(err.status || 400)
.json({
message: err.message,
error: {},
title: 'error'
}
);
});
module.exports = app;