diff --git a/website/server/controllers/api-v3/cron.js b/website/server/controllers/api-v3/cron.js new file mode 100644 index 0000000000..cf5e3b2e2d --- /dev/null +++ b/website/server/controllers/api-v3/cron.js @@ -0,0 +1,20 @@ +import { authWithHeaders } from '../../middlewares/auth'; +import cron from '../middlewares/cron'; + +let api = {}; + +/** + * @api {post} /api/v3/cron Runs cron + * @apiName Cron + * @apiGroup Cron + * + * @apiSuccess {Object} data An empty Object + */ +api.cron = { + method: 'POST', + url: '/debug/cron', + middlewares: [authWithHeaders(), cron], + async handler (req, res) { + res.respond(200, {}); + }, +}; diff --git a/website/server/libs/routes.js b/website/server/libs/routes.js index e341b9bca4..9e76af74c1 100644 --- a/website/server/libs/routes.js +++ b/website/server/libs/routes.js @@ -3,7 +3,6 @@ import _ from 'lodash'; import { getUserLanguage, } from '../middlewares/language'; -import cron from '../middlewares/cron'; // Wrapper function to handler `async` route handlers that return promises // It takes the async function, execute it and pass any error to next (args[2]) @@ -12,7 +11,7 @@ let noop = (req, res, next) => next(); module.exports.readController = function readController (router, controller) { _.each(controller, (action) => { - let {method, url, middlewares = [], handler, runCron} = action; + let {method, url, middlewares = [], handler} = action; // If an authentication middleware is used run getUserLanguage after it, otherwise before // for cron instead use it only if an authentication middleware is present