3 var express = require('express');
4 var resourceRoute = require('../../web/resource-route-generator');
5 var authMiddleware = require('../../web/middlewares/auth-api');
6 var identifyRoute = require('gitter-web-env').middlewares.identifyRoute;
8 var router = express.Router({ caseSensitive: true, mergeParams: true });
10 router.use('/user', authMiddleware);
11 router.use('/oauth-clients', authMiddleware);
12 router.use('/rooms', authMiddleware);
13 router.use('/users', authMiddleware);
14 router.use('/orgs', authMiddleware);
15 router.use('/groups', authMiddleware);
17 var userResources = resourceRoute('api-user', require('./user'));
18 const oauthClientsResources = resourceRoute('api-oauth-clients', require('./oauth-clients'));
19 var roomsResources = resourceRoute('api-rooms', require('./rooms'));
20 var usersResources = resourceRoute('api-rooms', require('./users'));
21 var orgResources = resourceRoute('api-orgs', require('./orgs'));
22 var groupsResources = resourceRoute('groups-orgs', require('./groups'));
24 router.use('/user', userResources);
25 router.use('/oauth-clients', oauthClientsResources);
26 router.use('/rooms', roomsResources);
27 router.use('/users', usersResources);
28 router.use('/orgs', orgResources);
29 router.use('/groups', groupsResources);
31 // APN has no auth requirement as user may not have authenticated
32 // and this is used for devices without users
33 router.post('/apn', identifyRoute('apn-registration'), require('./apn'));
35 // userapn ties together devices from /v1/apn and actual users.
36 // this definitely requires auth
40 identifyRoute('user-apn-registration'),
44 router.post('/eyeballs', authMiddleware, identifyRoute('eyeballs'), require('./eyeballs'));
46 router.delete('/sockets/:socketId', identifyRoute('remove-socket'), require('./sockets'));
48 router.get('/repo-info', authMiddleware, identifyRoute('repo-info'), require('./repo-info'));
53 identifyRoute('gcm-registration'),
54 require('./private/gcm')
57 module.exports = router;