reject on non-json content-types (#233)

This commit is contained in:
Thomas Hobson 2021-05-07 19:37:22 +12:00
parent 9590d5afbc
commit d95d67071c
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
1 changed files with 10 additions and 0 deletions

View File

@ -6,6 +6,16 @@ const {Job} = require("../job");
const package = require('../package') const package = require('../package')
const logger = require('logplease').create('api/v1'); const logger = require('logplease').create('api/v1');
router.use(function(req, res, next){
if(req.method == "POST" && req.headers['content-type'] !== "application/json")
return res
.status(415)
.send({
message: "requests must be of type application/json"
})
next();
})
router.post('/execute', async function(req, res){ router.post('/execute', async function(req, res){
const {language, version, files, stdin, args, run_timeout, compile_timeout} = req.body; const {language, version, files, stdin, args, run_timeout, compile_timeout} = req.body;