opt-cc/api/routes/command.js

42 lines
1009 B
JavaScript
Raw Normal View History

2017-05-10 11:04:06 +02:00
"use strict";
// modules
const express = require('express');
const logger = require('debug')('cc:command');
// HTTP status codes by name
const codes = require('./http-codes');
const routerHandling = require('../middleware/router-handling');
2017-07-23 11:07:47 +02:00
const createAllSignatures = require('../cron-job/cron').createAllSignatures;
2017-10-20 23:42:41 +02:00
const createSignature = require('../tools/signature-tool');
2017-05-10 11:04:06 +02:00
const command = express.Router();
2017-06-10 22:07:32 +02:00
command.route('/createSignature')
.post((req, res, next) => {
createAllSignatures();
})
.all(
routerHandling.httpMethodNotAllowed
);
2017-05-10 11:04:06 +02:00
command.route('/createSignature/:id')
.post((req, res, next) => {
const userId = req.params.id;
createSignature(userId, res, next);
})
.all(
routerHandling.httpMethodNotAllowed
);
// this middleware function can be used, if you like or remove it
// it looks for object(s) in res.locals.items and if they exist, they are send to the client as json
command.use(routerHandling.emptyResponse);
module.exports = command;