doc update

This commit is contained in:
2025-08-28 10:31:04 +02:00
parent 7489d7e2b1
commit 7e7fb72a3b
3 changed files with 18 additions and 73 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;
module.exports = router;