Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / api / private / index.js
blob771660f513f1672cdd06126127e3ffd07fbcf741
1 'use strict';
3 var express = require('express');
4 var authMiddleware = require('../../web/middlewares/auth-api');
5 const env = require('gitter-web-env');
6 const identifyRoute = env.middlewares.identifyRoute;
7 const logger = env.logger;
8 var skipTokenErrorHandler = require('../../web/middlewares/skip-token-error-handler');
10 var router = express.Router({ caseSensitive: true, mergeParams: true });
12 // No auth
13 router.get('/health_check', identifyRoute('api-private-health-check'), require('./health-check'));
15 // No auth
16 router.get(
17   '/health_check/full',
18   identifyRoute('api-private-health-check-full'),
19   require('./health-check-full')
22 // No auth
23 if (
24   process.env.ENABLE_FIXTURE_ENDPOINTS &&
25   (process.env.NODE_ENV === 'dev' ||
26     process.env.NODE_ENV === 'test' ||
27     process.env.NODE_ENV === 'test-docker')
28 ) {
29   logger.warn('Fixtures endpoint is enabled!');
30   router.use('/fixtures', require('./fixtures'));
33 router.get(
34   '/gh/repos/*',
35   authMiddleware,
36   identifyRoute('api-private-github-repo-mirror'),
37   require('./github-mirror/repos-mirror')
40 router.get(
41   '/gh/users/*',
42   authMiddleware,
43   identifyRoute('api-private-github-users-mirror'),
44   require('./github-mirror/users-mirror')
47 router.get(
48   '/gh/search/users',
49   authMiddleware,
50   identifyRoute('api-private-github-user-search-mirror'),
51   require('./github-mirror/user-search-mirror')
54 // No auth for hooks yet
55 router.post('/hook/:hash', identifyRoute('api-private-hook'), require('./hooks'));
57 router.get(
58   '/irc-token',
59   authMiddleware,
60   identifyRoute('api-private-irc-token'),
61   require('./irc-token')
64 router.get(
65   '/issue-mirror',
66   authMiddleware,
67   identifyRoute('api-private-issue-mirror'),
68   require('./issue-mirror')
71 router.get(
72   '/issue-state',
73   authMiddleware,
74   identifyRoute('api-private-issue-state'),
75   require('./issue-state')
78 router.get(
79   '/generate-signature',
80   authMiddleware,
81   identifyRoute('api-private-transloadit-signature'),
82   require('./transloadit-signature')
85 // No auth
86 router.post(
87   '/transloadit/:token',
88   identifyRoute('api-private-transloadit-callback'),
89   require('./transloadit')
92 router.get(
93   '/chat-heatmap/:roomId',
94   authMiddleware,
95   identifyRoute('api-private-chat-heatmap'),
96   require('./chat-heatmap')
99 router.get(
100   '/orgs/:orgUri/members',
101   authMiddleware,
102   skipTokenErrorHandler,
103   identifyRoute('api-private-org-members'),
104   require('./org-members')
107 router.post(
108   '/subscription/:userOrOrg',
109   identifyRoute('api-private-subscription-create'),
110   require('./subscription-created')
113 router.delete(
114   '/subscription/:userOrOrg',
115   identifyRoute('api-private-subscription-delete'),
116   require('./subscription-deleted')
119 router.post('/statsc', identifyRoute('api-private-statsc'), require('./statsc'));
121 router.get('/sample-chats', identifyRoute('api-private-sample-chats'), require('./sample-chats'));
123 router.post(
124   '/create-badge',
125   authMiddleware,
126   identifyRoute('api-private-create-badge'),
127   require('./create-badge-pr')
130 // TODO: this should go...
131 router.get(
132   '/user-avatar/:username',
133   identifyRoute('api-private-user-avatar'),
134   require('./user-avatar')
137 router.use('/avatars', require('./avatars'));
139 router.post(
140   '/markdown-preview',
141   authMiddleware,
142   identifyRoute('api-private-markdown-preview'),
143   require('./markdown-preview')
146 router.get(
147   '/inviteUserSuggestions',
148   authMiddleware,
149   identifyRoute('api-private-invite-user-suggestions'),
150   require('./invite-user-suggestions')
153 router.get(
154   '/check-invite',
155   authMiddleware,
156   identifyRoute('api-private-check-invite'),
157   require('./check-invite')
160 router.get(
161   '/check-group-uri',
162   authMiddleware,
163   identifyRoute('api-private-check-group-uri'),
164   require('./check-group-uri')
167 router.post('/fp', authMiddleware, identifyRoute('api-private-fp'), require('./fingerprint'));
169 router.get(
170   /^\/resolve\/(.*)$/,
171   authMiddleware,
172   identifyRoute('api-private-resolve'),
173   require('./resolve')
176 /* Web push registration endpoint */
177 router.post('/vapid', authMiddleware, identifyRoute('api-private-vapid'), require('./vapid'));
179 module.exports = router;