Skip to content

Commit d4f7ffe

Browse files
committed
added GET /help route (Thor would be proud)
1 parent c469eda commit d4f7ffe

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# httpbin
22

3-
HTTP server for debugging clients
3+
HTTP server for debugging clients.
4+
5+
## Run the server
6+
7+
```shell
8+
$ npx @buzuli/httpbin
9+
```

lib/server.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ function server (options = {}) {
1919

2020
const app = express()
2121

22+
const summary = 'Any route (other than GET /help) will respond with the ' +
23+
'normal response (JSON body detailing the request). Query parameters ' +
24+
'are used for all behavior modification.'
25+
26+
const params = {
27+
delay: '[number] milliseconds to delay before seding a response',
28+
status: '[number] HTTP status code to respond with'
29+
}
30+
31+
app.get('/help', (req, res) => {
32+
res
33+
.json({
34+
summary,
35+
params
36+
})
37+
})
38+
2239
app.use(bodyParser.json())
2340
app.use(bodyParser.urlencoded({extended: true}))
2441
app.use(bodyParser.text())

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
"@buzuli/json": "^1.1.3",
2020
"axios": "^0.18.0",
2121
"body-parser": "^1.18.3",
22-
"express": "^4.16.3",
22+
"express": "^4.16.4",
2323
"log-a-log": "^6.0.0",
2424
"ramda": "^0.25.0",
25-
"yargs": "^12.0.1"
25+
"yargs": "^12.0.2"
2626
},
2727
"devDependencies": {
28-
"nodemon": "^1.18.3"
28+
"nodemon": "^1.18.4"
2929
}
3030
}

0 commit comments

Comments
 (0)