Skip to content

Commit ca39a92

Browse files
committed
chore: return 204 for successful POST requests
1 parent f405a4c commit ca39a92

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Generates the endpoints (or a whole app) from a mapping (SQL query -> URL)
6363
3
6464
$ curl http://localhost:3000/v1/collections/1/categories/count
6565
1
66-
$ curl -H 'Content-Type: application/json' -d '{"name":"Sport","slug":"sport","userId":100}' http://localhost:3000/v1/categories
67-
OK
66+
$ curl -i -H 'Content-Type: application/json' -d '{"name":"Sport","nameRu":"Спорт","slug":"sport","userId":100}' http://localhost:3000/v1/categories
67+
HTTP/1.1 204 No Content
68+
ETag: W/"a-bAsFyilMr4Ra1hIU5PyoyFRunpI"
69+
Date: Wed, 15 Jul 2020 18:06:33 GMT
70+
Connection: keep-alive
6871
```

examples/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ app.post('/v1/categories', (req, res) => {
6262
if (err) {
6363
throw err
6464
}
65-
res.sendStatus(200)
65+
res.sendStatus(204)
6666
}
6767
)
6868
})

src/templates/app.js.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ app.post('<%- endpoint.path %>', (req, res) => {
5555
if (err) {
5656
throw err
5757
}
58-
res.sendStatus(200)
58+
res.sendStatus(204)
5959
}
6060
)
6161
})

0 commit comments

Comments
 (0)