Skip to content

Commit c32b42a

Browse files
committed
Configurable response HTTP status code
1 parent c4b193a commit c32b42a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Clone this repo, then inside of it:
2020

2121
```
2222
npm install
23-
PORT=3333 npm start
23+
PORT=3333 RESPONSE_STATUS=204 npm start
2424
```
2525

2626
Then, watch the output to inspect incoming requests:

server.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const express = require('express');
22
const bodyParser = require('body-parser')
33

44
const port = process.env.PORT || 3333;
5+
const responseStatus = +(process.env.RESPONSE_STATUS || 200);
56

67
const app = express();
78

@@ -25,7 +26,7 @@ ${headers.join("\n")}${req.body.constructor === Object && Object.keys(req.body).
2526
`);
2627

2728
// Always respond successful.
28-
res.sendStatus(200);
29+
res.sendStatus(responseStatus);
2930
});
3031

3132
app.listen(port, (err) => {

0 commit comments

Comments
 (0)