diff --git a/doc/api.md b/doc/api.md index 4937272..a5ab9fb 100644 --- a/doc/api.md +++ b/doc/api.md @@ -4,7 +4,13 @@ ## Base URL ``` -http://localhost:3000 +http://localhost:3000/api +``` + +**Default Headers:** + +``` +Content-Type: application/json ``` --- @@ -21,11 +27,6 @@ Sorts an array (numeric or alphabetical) and returns the sorted array. POST /sort ``` -**Headers:** - -``` -Content-Type: application/json -``` **Body Example:** @@ -43,16 +44,8 @@ Content-Type: application/json } ``` -### Error Responses -| Status Code | Description | -| ----------- | ----------------------------------------------- | -| `400` | Request body missing or `array` is not an array | -| `500` | Unexpected server error | - ---- - -## 2️⃣ POST `/is-odd` +## 2️⃣ POST `/isOdd` Checks if a given number is odd. @@ -61,13 +54,7 @@ Checks if a given number is odd. **URL:** ``` -POST /is-odd -``` - -**Headers:** - -``` -Content-Type: application/json +POST /isOdd ``` **Body Example:** @@ -82,30 +69,13 @@ Content-Type: application/json ```json { - "number": 7, - "isOdd": true + "ret": true } ``` -**Example with an even number:** - -```json -{ - "number": 4, - "isOdd": false -} -``` - -### Error Responses - -| Status Code | Description | -| ----------- | ------------------------------------------------------ | -| `400` | Request body missing or `number` is not a valid number | -| `500` | Unexpected server error | - --- -## 3️⃣ POST `/is-even` +## 3️⃣ POST `/isEven` Checks if a given number is even. @@ -114,13 +84,7 @@ Checks if a given number is even. **URL:** ``` -POST /is-even -``` - -**Headers:** - -``` -Content-Type: application/json +POST /isEven ``` **Body Example:** @@ -135,29 +99,10 @@ Content-Type: application/json ```json { - "number": 4, - "isEven": true + "ret": true } ``` -**Example with an odd number:** - -```json -{ - "number": 7, - "isEven": false -} -``` - -### Error Responses - -| Status Code | Description | -| ----------- | ------------------------------------------------------ | -| `400` | Request body missing or `number` is not a valid number | -| `500` | Unexpected server error | - ---- - ## 📌 Example Usage with `curl` ### Sort an array (Linux/macOS) diff --git a/src/routes/api/isEven.js b/src/routes/api/isEven.js index 51e6a8e..a654c39 100644 --- a/src/routes/api/isEven.js +++ b/src/routes/api/isEven.js @@ -3,9 +3,9 @@ const isEven = require('is-even'); const router = express.Router(); router.post('/', (req, res) => { - const { num } = req.body; + const { number } = req.body; - res.json({ ret: isEven(num) }); + res.json({ ret: isEven(number) }); }); module.exports = router; \ No newline at end of file diff --git a/src/routes/api/isOdd.js b/src/routes/api/isOdd.js index 5281af8..09e88b8 100644 --- a/src/routes/api/isOdd.js +++ b/src/routes/api/isOdd.js @@ -3,9 +3,9 @@ const isOdd = require('is-odd'); const router = express.Router(); router.post('/', (req, res) => { - const { num } = req.body; + const { number } = req.body; - res.json({ ret: isOdd(num) }); + res.json({ ret: isOdd(number) }); }); -module.exports = router; \ No newline at end of file +module.exports = router;