Added cron route

This commit is contained in:
Keith Holliday
2017-06-08 14:07:33 -07:00
parent 137636cb40
commit 60de7c8f21
2 changed files with 21 additions and 2 deletions

View File

@@ -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, {});
},
};

View File

@@ -3,7 +3,6 @@ import _ from 'lodash';
import { import {
getUserLanguage, getUserLanguage,
} from '../middlewares/language'; } from '../middlewares/language';
import cron from '../middlewares/cron';
// Wrapper function to handler `async` route handlers that return promises // 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]) // 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) { module.exports.readController = function readController (router, controller) {
_.each(controller, (action) => { _.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 // If an authentication middleware is used run getUserLanguage after it, otherwise before
// for cron instead use it only if an authentication middleware is present // for cron instead use it only if an authentication middleware is present