Use objects instead of a list of parameters

This commit is contained in:
Daniel García Aubert
2018-03-14 17:22:47 +01:00
parent 2cc4161239
commit 421e611356

View File

@@ -26,7 +26,7 @@ NamedMapsAdminController.prototype.register = function (app) {
userMiddleware(),
localsMiddleware(),
credentialsMiddleware(),
checkContentType('POST', 'POST TEMPLATE'),
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
authorizedByAPIKey(this.authApi, 'create', 'POST TEMPLATE'),
createTemplate(this.templateMaps),
sendResponse()
@@ -38,7 +38,7 @@ NamedMapsAdminController.prototype.register = function (app) {
userMiddleware(),
localsMiddleware(),
credentialsMiddleware(),
checkContentType('PUT', 'PUT TEMPLATE'),
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
authorizedByAPIKey(this.authApi, 'update', 'PUT TEMPLATE'),
updateTemplate(this.templateMaps),
sendResponse()
@@ -83,7 +83,7 @@ NamedMapsAdminController.prototype.register = function (app) {
);
};
function checkContentType (action, label) {
function checkContentType ({ action, label }) {
return function checkContentTypeMiddleware (req, res, next) {
if (!req.is('application/json')) {
const error = new Error(`template ${action} data must be of type application/json`);