api: lint
This commit is contained in:
parent
8b61f4f69f
commit
764641b5a6
|
@ -8,26 +8,26 @@ const { body } = require('express-validator');
|
|||
module.exports = {
|
||||
run_job_validators: [
|
||||
body('language')
|
||||
.isString(),
|
||||
.isString(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('version')
|
||||
.isSemVer(),
|
||||
.isSemVer(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('files')
|
||||
.isArray(),
|
||||
.isArray(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('files.*.name')
|
||||
.isString()
|
||||
.isString() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.not()
|
||||
.contains('/'),
|
||||
body('files.*.content')
|
||||
.isString(),
|
||||
.isString(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('*_timeout')
|
||||
.isNumeric(),
|
||||
.isNumeric(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('stdin')
|
||||
.isString(),
|
||||
.isString(), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('args')
|
||||
.isArray(),
|
||||
body('args.*')
|
||||
.isString()
|
||||
.isString() // eslint-disable-line snakecasejs/snakecasejs
|
||||
],
|
||||
async run_job(req, res){
|
||||
// POST /jobs
|
||||
|
|
|
@ -11,7 +11,7 @@ const fs = require('fs/promises');
|
|||
const fss = require('fs');
|
||||
const body_parser = require('body-parser');
|
||||
const runtime = require('./runtime');
|
||||
const {validationResult} = require('express-validator');
|
||||
const {validationResult} = require('express-validator'); //eslint-disable-line snakecasejs/snakecasejs
|
||||
|
||||
const logger = Logger.create('index');
|
||||
const app = express();
|
||||
|
@ -77,8 +77,8 @@ const app = express();
|
|||
|
||||
|
||||
function validate(req, res, next) {
|
||||
const errors = validationResult(req);
|
||||
if (!errors.isEmpty())
|
||||
const errors = validationResult(req); //eslint-disable-line snakecasejs/snakecasejs
|
||||
if (!errors.isEmpty()) //eslint-disable-line snakecasejs/snakecasejs
|
||||
return res.json_error(errors.array(), 422);
|
||||
next();
|
||||
}
|
||||
|
|
|
@ -42,17 +42,17 @@ module.exports = {
|
|||
},
|
||||
repo_add_validators: [
|
||||
body('slug')
|
||||
.notEmpty()
|
||||
.notEmpty() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.isSlug()
|
||||
.isSlug() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.not()
|
||||
.custom(value=>state.state.get('repositories').keys().includes(value))
|
||||
.withMessage("slug is already in use"),
|
||||
.withMessage('slug is already in use'), // eslint-disable-line snakecasejs/snakecasejs
|
||||
body('url')
|
||||
.notEmpty()
|
||||
.notEmpty() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.isURL({require_protocol: true})
|
||||
.isURL({require_protocol: true}) // eslint-disable-line snakecasejs/snakecasejs
|
||||
|
||||
],
|
||||
async repo_add(req, res){
|
||||
|
@ -69,10 +69,10 @@ module.exports = {
|
|||
},
|
||||
repo_info_validators: [
|
||||
param('repo_slug')
|
||||
.isSlug()
|
||||
.isSlug() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.custom(value=>state.state.get('repositories').has(value))
|
||||
.withMessage("repository does not exist")
|
||||
.withMessage('repository does not exist') // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
],
|
||||
async repo_info(req, res){
|
||||
|
@ -89,10 +89,10 @@ module.exports = {
|
|||
},
|
||||
repo_packages_validators: [
|
||||
param('repo_slug')
|
||||
.isSlug()
|
||||
.isSlug() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.custom(value=>state.state.get('repositories').has(value))
|
||||
.withMessage("repository does not exist")
|
||||
.withMessage('repository does not exist') // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
],
|
||||
async repo_packages(req, res){
|
||||
|
@ -112,10 +112,10 @@ module.exports = {
|
|||
},
|
||||
package_info_validators: [
|
||||
param('repo_slug')
|
||||
.isSlug()
|
||||
.isSlug() // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
.custom(value=>state.state.get('repositories').has(value))
|
||||
.withMessage("repository does not exist")
|
||||
.withMessage('repository does not exist') // eslint-disable-line snakecasejs/snakecasejs
|
||||
.bail()
|
||||
],
|
||||
async package_info(req, res){
|
||||
|
@ -161,6 +161,6 @@ module.exports = {
|
|||
// DELETE /repos/:slug/packages/:language/:version
|
||||
|
||||
//res.json(req.body); //TODO
|
||||
res.json_error("not implemented", 500)
|
||||
res.json_error('not implemented', 500);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue