-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
36 lines (29 loc) · 1.43 KB
/
router.js
File metadata and controls
36 lines (29 loc) · 1.43 KB
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
"use strict";
const Authentication = require('./controllers/authentication');
const Photon = require('./controllers/photon');
const passportService = require('./services/passport');
const passport = require('passport');
// session : false, not save cookies (working with jwt)
const requireAuth = passport.authenticate('jwt', { session: false });
const requireSignin = passport.authenticate('local', { session: false });
module.exports = function(app) {
app.get('/', requireAuth, function(req, res) {
return res.sendStatus(200);
});
app.get('/health', function(req, res) {
return res.sendStatus(200);
});
app.post('/signin', requireSignin, Authentication.signin);
app.post('/signup', Authentication.signup);
app.post('/sendSocketInformation', Photon.sendSocketInformation);
app.post('/changeSocketStatus', Photon.changeSocketStatus);
app.get('/getServerInformation', Photon.getServerInformation);
app.post('/claimDevice', requireAuth, Photon.claimDevice);
app.get('/listDevices', requireAuth, Photon.listDevices);
app.get('/deviceDetails', requireAuth, Photon.deviceDetails);
app.get('/deviceMostRecentData', requireAuth, Photon.deviceMostRecentData);
app.post('/changeDeviceStatus', requireAuth, Photon.changeDeviceStatus);
app.post('/changeDeviceName', requireAuth, Photon.changeDeviceName);
app.post('/generateReport', requireAuth, Photon.generateReport);
app.post('/particle/oauth/token', Photon.particleOAuth);
};