forked from jmcooper/ng2f-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
49 lines (39 loc) · 1.42 KB
/
routes.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
45
46
47
48
49
var auth = require('./auth'),
events = require('./controllers/eventController'),
users = require('./controllers/userController');
path = require('path');
var fs = require('fs');
module.exports = function(app) {
app.post('/api/login', auth.authenticate);
app.get('/api/currentIdentity', auth.getCurrentIdentity);
app.put('/api/users/:id', users.updateUser);
app.get('/api/events', events.getEvents);
app.get('/api/events/:eventId', events.getEvent);
app.post('/api/events', events.saveEvent);
app.get('/api/sessions/search', events.searchSessions);
app.delete('/api/events/:eventId/sessions/:sessionId/voters/:voterId', events.deleteVoter);
app.post('/api/events/:eventId/sessions/:sessionId/voters/:voterId', events.addVoter);
app.post('/api/logout', function(req, res) {
req.logout();
res.end();
});
app.get('/app/*', function(req, res) {
res.sendStatus(404);
});
app.get('/node_modules/*', function(req, res) {
res.sendStatus(404);
});
app.get('/events/*', function(req, res) {
res.sendFile(path.resolve(__dirname + '/../../index.html'));
});
app.get('/user/*', function(req, res) {
res.sendFile(path.resolve(__dirname + '/../../index.html'));
});
app.get('/404', function(req, res) {
res.sendFile(path.resolve(__dirname + '/../../index.html'));
});
app.get('*', function(req, res) {
console.log('404 error', req.path);
res.sendStatus(404);
});
}