Use objects instead of parameter list

This commit is contained in:
Daniel García Aubert
2018-03-14 17:25:58 +01:00
parent 421e611356
commit 8d37e00869
+6 -6
View File
@@ -27,7 +27,7 @@ NamedMapsAdminController.prototype.register = function (app) {
localsMiddleware(),
credentialsMiddleware(),
checkContentType({ action: 'POST', label: 'POST TEMPLATE' }),
authorizedByAPIKey(this.authApi, 'create', 'POST TEMPLATE'),
authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }),
createTemplate(this.templateMaps),
sendResponse()
);
@@ -39,7 +39,7 @@ NamedMapsAdminController.prototype.register = function (app) {
localsMiddleware(),
credentialsMiddleware(),
checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }),
authorizedByAPIKey(this.authApi, 'update', 'PUT TEMPLATE'),
authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }),
updateTemplate(this.templateMaps),
sendResponse()
);
@@ -50,7 +50,7 @@ NamedMapsAdminController.prototype.register = function (app) {
userMiddleware(),
localsMiddleware(),
credentialsMiddleware(),
authorizedByAPIKey(this.authApi, 'get', 'GET TEMPLATE'),
authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }),
retrieveTemplate(this.templateMaps),
sendResponse()
);
@@ -61,7 +61,7 @@ NamedMapsAdminController.prototype.register = function (app) {
userMiddleware(),
localsMiddleware(),
credentialsMiddleware(),
authorizedByAPIKey(this.authApi, 'delete', 'DELETE TEMPLATE'),
authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }),
destroyTemplate(this.templateMaps),
sendResponse()
);
@@ -72,7 +72,7 @@ NamedMapsAdminController.prototype.register = function (app) {
userMiddleware(),
localsMiddleware(),
credentialsMiddleware(),
authorizedByAPIKey(this.authApi, 'list', 'GET TEMPLATE LIST'),
authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }),
listTemplates(this.templateMaps),
sendResponse()
);
@@ -95,7 +95,7 @@ function checkContentType ({ action, label }) {
};
}
function authorizedByAPIKey (authApi, action, label) {
function authorizedByAPIKey ({ authApi, action, label }) {
return function authorizedByAPIKeyMiddleware (req, res, next) {
const { user } = res.locals;