doc update
This commit is contained in:
81
doc/api.md
81
doc/api.md
@@ -4,7 +4,13 @@
|
|||||||
## Base URL
|
## 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
|
POST /sort
|
||||||
```
|
```
|
||||||
|
|
||||||
**Headers:**
|
|
||||||
|
|
||||||
```
|
|
||||||
Content-Type: application/json
|
|
||||||
```
|
|
||||||
|
|
||||||
**Body Example:**
|
**Body Example:**
|
||||||
|
|
||||||
@@ -43,16 +44,8 @@ Content-Type: application/json
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Error Responses
|
|
||||||
|
|
||||||
| Status Code | Description |
|
## 2️⃣ POST `/isOdd`
|
||||||
| ----------- | ----------------------------------------------- |
|
|
||||||
| `400` | Request body missing or `array` is not an array |
|
|
||||||
| `500` | Unexpected server error |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2️⃣ POST `/is-odd`
|
|
||||||
|
|
||||||
Checks if a given number is odd.
|
Checks if a given number is odd.
|
||||||
|
|
||||||
@@ -61,13 +54,7 @@ Checks if a given number is odd.
|
|||||||
**URL:**
|
**URL:**
|
||||||
|
|
||||||
```
|
```
|
||||||
POST /is-odd
|
POST /isOdd
|
||||||
```
|
|
||||||
|
|
||||||
**Headers:**
|
|
||||||
|
|
||||||
```
|
|
||||||
Content-Type: application/json
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Body Example:**
|
**Body Example:**
|
||||||
@@ -82,30 +69,13 @@ Content-Type: application/json
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"number": 7,
|
"ret": true
|
||||||
"isOdd": 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.
|
Checks if a given number is even.
|
||||||
|
|
||||||
@@ -114,13 +84,7 @@ Checks if a given number is even.
|
|||||||
**URL:**
|
**URL:**
|
||||||
|
|
||||||
```
|
```
|
||||||
POST /is-even
|
POST /isEven
|
||||||
```
|
|
||||||
|
|
||||||
**Headers:**
|
|
||||||
|
|
||||||
```
|
|
||||||
Content-Type: application/json
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Body Example:**
|
**Body Example:**
|
||||||
@@ -135,29 +99,10 @@ Content-Type: application/json
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"number": 4,
|
"ret": true
|
||||||
"isEven": 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`
|
## 📌 Example Usage with `curl`
|
||||||
|
|
||||||
### Sort an array (Linux/macOS)
|
### Sort an array (Linux/macOS)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ const isEven = require('is-even');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post('/', (req, res) => {
|
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;
|
module.exports = router;
|
||||||
@@ -3,9 +3,9 @@ const isOdd = require('is-odd');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post('/', (req, res) => {
|
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;
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user