api: fix validators

This commit is contained in:
Thomas Hobson 2021-02-27 23:10:54 +13:00
parent 3ab6aefe05
commit b91ff42bb8
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
2 changed files with 6 additions and 3 deletions

View File

@ -10,7 +10,8 @@ module.exports = {
body('language') body('language')
.isString(), // eslint-disable-line snakecasejs/snakecasejs .isString(), // eslint-disable-line snakecasejs/snakecasejs
body('version') body('version')
.isSemVer(), // eslint-disable-line snakecasejs/snakecasejs .isString(), // eslint-disable-line snakecasejs/snakecasejs
// isSemVer requires it to be a version, not a selector
body('files') body('files')
.isArray(), // eslint-disable-line snakecasejs/snakecasejs .isArray(), // eslint-disable-line snakecasejs/snakecasejs
body('files.*.name') body('files.*.name')
@ -20,7 +21,9 @@ module.exports = {
.contains('/'), .contains('/'),
body('files.*.content') body('files.*.content')
.isString(), // eslint-disable-line snakecasejs/snakecasejs .isString(), // eslint-disable-line snakecasejs/snakecasejs
body('*_timeout') body('compile_timeout')
.isNumeric(), // eslint-disable-line snakecasejs/snakecasejs
body('run_timeout')
.isNumeric(), // eslint-disable-line snakecasejs/snakecasejs .isNumeric(), // eslint-disable-line snakecasejs/snakecasejs
body('stdin') body('stdin')
.isString(), // eslint-disable-line snakecasejs/snakecasejs .isString(), // eslint-disable-line snakecasejs/snakecasejs

View File

@ -52,7 +52,7 @@ module.exports = {
body('url') body('url')
.notEmpty() // eslint-disable-line snakecasejs/snakecasejs .notEmpty() // eslint-disable-line snakecasejs/snakecasejs
.bail() .bail()
.isURL({require_protocol: true}) // eslint-disable-line snakecasejs/snakecasejs .isURL({require_host: false, require_protocol: true, protocols: ['http','https','file']}) // eslint-disable-line snakecasejs/snakecasejs
], ],
async repo_add(req, res){ async repo_add(req, res){