apps: add crontab

crontab is a text field, so we can have comments

part of #793
This commit is contained in:
Girish Ramakrishnan
2021-09-27 14:21:42 -07:00
parent 04ff8dab1b
commit b86d5ea0ea
6 changed files with 89 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ exports = module.exports = {
setAccessRestriction,
setOperators,
setCrontab,
setLabel,
setTags,
setIcon,
@@ -196,6 +197,18 @@ async function setOperators(req, res, next) {
next(new HttpSuccess(200, {}));
}
async function setCrontab(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (req.body.crontab !== null && typeof req.body.crontab !== 'string') return next(new HttpError(400, 'crontab must be a string'));
const [error] = await safe(apps.setCrontab(req.app, req.body.crontab, auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
}
async function setLabel(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');