mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Added cron route
This commit is contained in:
20
website/server/controllers/api-v3/cron.js
Normal file
20
website/server/controllers/api-v3/cron.js
Normal 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, {});
|
||||
},
|
||||
};
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user