ffffng/server/router.js

53 lines
2.2 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
2018-12-17 22:49:54 +01:00
const express = require('express');
const app = require('./app')
const config = require('./config').config
const VersionResource = require('./resources/versionResource')
const StatisticsResource = require('./resources/statisticsResource')
const FrontendResource = require('./resources/frontendResource')
const NodeResource = require('./resources/nodeResource')
const MonitoringResource = require('./resources/monitoringResource')
const TaskResource = require('./resources/taskResource')
const MailResource = require('./resources/mailResource')
module.exports = {
init () {
const router = express.Router();
router.post('/', FrontendResource.render);
router.get('/api/version', VersionResource.get);
router.post('/api/node', NodeResource.create);
router.put('/api/node/:token', NodeResource.update);
router.delete('/api/node/:token', NodeResource.delete);
router.get('/api/node/:token', NodeResource.get);
router.put('/api/monitoring/confirm/:token', MonitoringResource.confirm);
router.put('/api/monitoring/disable/:token', MonitoringResource.disable);
router.get('/internal/api/statistics', StatisticsResource.get);
router.get('/internal/api/tasks', TaskResource.getAll);
router.put('/internal/api/tasks/run/:id', TaskResource.run);
router.put('/internal/api/tasks/enable/:id', TaskResource.enable);
router.put('/internal/api/tasks/disable/:id', TaskResource.disable);
router.get('/internal/api/monitoring', MonitoringResource.getAll);
router.get('/internal/api/mails', MailResource.getAll);
router.get('/internal/api/mails/:id', MailResource.get);
router.delete('/internal/api/mails/:id', MailResource.delete);
router.put('/internal/api/mails/reset/:id', MailResource.resetFailures);
router.put('/internal/api/nodes/:token', NodeResource.update);
router.delete('/internal/api/nodes/:token', NodeResource.delete);
router.get('/internal/api/nodes', NodeResource.getAll);
router.get('/internal/api/nodes/:token', NodeResource.get);
app.use(config.server.rootPath, router);
}
}