Skip to content

Commit 17c4fdb

Browse files
authored
Merge pull request #537 from Vrganj/master
return 200 and piston ver on /, fix empty content-type header validation
2 parents 7441f26 + e86c19b commit 17c4fdb

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "piston-api",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "API for piston - a high performance code execution engine",
55
"main": "src/index.js",
66
"dependencies": {

api/src/api/v2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ router.use((req, res, next) => {
163163
return next();
164164
}
165165

166-
if (!req.headers['content-type'].startsWith('application/json')) {
166+
if (!req.headers['content-type']?.startsWith('application/json')) {
167167
return res.status(415).send({
168168
message: 'requests must be of type application/json',
169169
});

api/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ expressWs(app);
7979
const api_v2 = require('./api/v2');
8080
app.use('/api/v2', api_v2);
8181

82+
const { version } = require('../package.json');
83+
84+
app.get('/', (req, res, next) => {
85+
return res.status(200).send({ message: `Piston v${version}` });
86+
});
87+
8288
app.use((req, res, next) => {
8389
return res.status(404).send({ message: 'Not Found' });
8490
});

0 commit comments

Comments
 (0)