Skip to content

Commit

Permalink
Configurable response HTTP status code
Browse files Browse the repository at this point in the history
  • Loading branch information
mars committed Apr 10, 2019
1 parent c4b193a commit c32b42a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Clone this repo, then inside of it:

```
npm install
PORT=3333 npm start
PORT=3333 RESPONSE_STATUS=204 npm start
```

Then, watch the output to inspect incoming requests:
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const bodyParser = require('body-parser')

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

const app = express();

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

// Always respond successful.
res.sendStatus(200);
res.sendStatus(responseStatus);
});

app.listen(port, (err) => {
Expand Down

0 comments on commit c32b42a

Please sign in to comment.