-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.js
42 lines (31 loc) · 1.39 KB
/
router.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
const express = require('express')
const router = express.Router()
const cors = require('cors')
const bodyParser = require('body-parser')
const guard = require('./middlewares/guard')
const itemCrud = require('./middlewares/item_crud')
const ctrl = require('./controllers')
// unprotected routes
router.use(express.static('webapp/build'))
router.use(cors())
router.use(bodyParser.json({ limit: '30mb' }))
router.post('/api/login', ctrl.SessionsController.create)
router.delete('/api/logout', ctrl.SessionsController.destroy)
router.post('/api/users', ctrl.UsersController.create) // unprotected for first user
if (process.env.NODE_ENV === 'test') {
router.post('/api/integration_test', ctrl.IntegrationTestsController.create)
router.use('/plugin', express.static('../plugin/build/default'))
}
// protected routes
router.use(guard())
router.use(itemCrud())
router.get('/api/check/:url', ctrl.ChecksController.show)
router.get('/api/export', ctrl.ExportsController.show)
router.get('/api/health_check', ctrl.HealthChecksController.show)
router.post('/api/items/:id/dissolve', ctrl.DissolutionsController.create)
router.post('/api/imports', ctrl.ImportsController.create)
router.get('/api/stats', ctrl.StatsController.show)
router.get('/api/user', ctrl.UsersController.show)
router.put('/api/user', ctrl.UsersController.update)
router.delete('/api/user', ctrl.UsersController.destroy)
module.exports = router