Added development controller, middleware, and initial tests
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { authWithHeaders } from '../../middlewares/api-v3/auth';
|
||||
import cron from '../../middlewares/api-v3/cron';
|
||||
import checkForDevelopmentMode from '../../middlewares/api-v3/developmentMode';
|
||||
|
||||
let api = {};
|
||||
|
||||
/**
|
||||
* @api {post} /development/addTenGems Add ten gems to the current user
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName AddTenGems
|
||||
* @apiGroup Development
|
||||
*
|
||||
* @apiSuccess {} An empty Object
|
||||
*/
|
||||
api.addTenGems = {
|
||||
method: 'POST',
|
||||
url: '/development/addTenGems',
|
||||
middlewares: [checkForDevelopmentMode, authWithHeaders(), cron],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
user.balance += 2.5;
|
||||
|
||||
await user.save();
|
||||
|
||||
res.respond(200, {});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /development/addHourglass Add Hourglass to the current user
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName AddHourglass
|
||||
* @apiGroup Development
|
||||
*
|
||||
* @apiSuccess {} An empty Object
|
||||
*/
|
||||
api.addHourglass = {
|
||||
method: 'POST',
|
||||
url: '/development/addHourglass',
|
||||
middlewares: [checkForDevelopmentMode, authWithHeaders(), cron],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
user.purchased.plan.consecutive.trinkets += 1;
|
||||
|
||||
await user.save();
|
||||
|
||||
res.respond(200, {});
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
@@ -0,0 +1,12 @@
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
NotFound,
|
||||
} from '../../libs/api-v3/errors';
|
||||
|
||||
module.exports = function checkForDevelopmentMode (req, res, next) {
|
||||
if (nconf.get('IS_PROD')) {
|
||||
next(new NotFound());
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user