-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (30 loc) · 897 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
/* Setup */
const express = require('express'),
app = express(),
passport = require('passport'),
auth = require('./src/auth/AuthService');
cors = require('cors');
app.set('port', process.env.PORT || 3000);
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
/* Exposed endpoints */
require('./src/auth/AuthController')(app);
require('./src/user/UserController')(app);
require('./src/book/SearchController')(app);
// -----------------------------------------------
app.get('/', function(req, res) {
res.json({token: req.session.token});
})
app.listen(app.get('port'), function() {
console.log('Express started...')
console.log('on port' + app.get('port'));
});
function errorHandler (err, req, res, next) {
console.log("HANDLING ERRORS!!!!!!!!")
res.status(500)
res.json("error!");
}
app.use(errorHandler)