opt-cc/api/routes/command.js

42 lines
1009 B
JavaScript

"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');
const createAllSignatures = require('../cron-job/cron').createAllSignatures;
const createSignature = require('../tools/signature-tool');
const command = express.Router();
command.route('/createSignature')
.post((req, res, next) => {
createAllSignatures();
})
.all(
routerHandling.httpMethodNotAllowed
);
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;