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')
|
2018-02-26 09:04:27 +01:00
|
|
|
.post((req, res, next) => {
|
|
|
|
createAllSignatures();
|
|
|
|
})
|
2017-06-10 22:07:32 +02:00
|
|
|
|
2018-02-26 09:04:27 +01:00
|
|
|
.all(
|
|
|
|
routerHandling.httpMethodNotAllowed
|
|
|
|
);
|
2017-05-10 11:04:06 +02:00
|
|
|
|
|
|
|
command.route('/createSignature/:id')
|
2018-02-26 09:04:27 +01:00
|
|
|
.post((req, res, next) => {
|
|
|
|
const userId = req.params.id;
|
|
|
|
createSignature(userId, res, next);
|
|
|
|
})
|
|
|
|
|
|
|
|
.all(
|
|
|
|
routerHandling.httpMethodNotAllowed
|
|
|
|
);
|
2017-05-10 11:04:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
// 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;
|