opt-cc/opt-cc-api/routes/command.js

34 lines
896 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 createSignature = require('../signature-tool/signature-tool');
const command = express.Router();
// add middleware for bonus tasks 4 and 5 to find filter and offset/limit params for GET / and GET /:id
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;