-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
67 lines (52 loc) · 1.44 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
var api = require('./controllers/api'),
index = require('./controllers'),
users = require('./controllers/users'),
fields = require('./controllers/fields'),
logins = require('./controllers/logins'),
session = require('./controllers/session'),
sync = require('./controllers/sync'),
fprocess = require('./controllers/process'),
middleware = require('./middleware');
/**
* Application routes
*/
module.exports = function (app) {
// Server API Routes
app.route('/api/users')
.post(users.create);
app.route('/api/users/me')
.get(users.me)
.put(users.updateMe);
app.route('/api/users/:id')
.get(users.show);
app.route('/api/session')
.post(session.login)
.delete(session.logout);
app.route('/api/fields')
.get(fields.getAll)
.post(fields.create);
app.route('/api/fields/:id')
.get(fields.getOne)
.put(fields.updateOne)
.post(fields.sendMessages)
.delete(fields.deleteOne);
app.route('/api/logins')
.get(logins.getAll);
app.route('/api/logins/:name')
.get(logins.getOne);
app.route('/api/sync')
.post(sync.update);
app.route('/api/process/:data')
.get(fprocess.validate);
// All undefined api routes should return a 404
app.route('/api/*')
.get(function (req, res) {
res.send(404);
});
// All other routes to use Angular routing in app/scripts/app.js
app.route('/partials/*')
.get(index.partials);
app.route('/*')
.get(middleware.setUserCookie, index.index);
};