Merge pull request #537 from Vrganj/master

return 200 and piston ver on /, fix empty content-type header validation
This commit is contained in:
Thomas Hobson 2023-01-12 15:21:06 +13:00 committed by GitHub
commit 17c4fdb51e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "piston-api",
"version": "3.1.0",
"version": "3.1.1",
"description": "API for piston - a high performance code execution engine",
"main": "src/index.js",
"dependencies": {

View File

@ -163,7 +163,7 @@ router.use((req, res, next) => {
return next();
}
if (!req.headers['content-type'].startsWith('application/json')) {
if (!req.headers['content-type']?.startsWith('application/json')) {
return res.status(415).send({
message: 'requests must be of type application/json',
});

View File

@ -79,6 +79,12 @@ expressWs(app);
const api_v2 = require('./api/v2');
app.use('/api/v2', api_v2);
const { version } = require('../package.json');
app.get('/', (req, res, next) => {
return res.status(200).send({ message: `Piston v${version}` });
});
app.use((req, res, next) => {
return res.status(404).send({ message: 'Not Found' });
});