Compare commits
9 Commits
8ac8643e6d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5be3d127bb | ||
|
|
aacb2f4287 | ||
|
|
d1edd55b36 | ||
|
|
093bdd3625 | ||
|
|
c0f81934be | ||
|
|
1924b1d262 | ||
|
|
9228ebbe5b | ||
|
|
f8c4e3c688 | ||
|
|
88ef8136f3 |
28
.gitea/workflows/release.yml
Normal file
28
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Build Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Gitea Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
||||||
|
docker login https://gitea.johannesbot.de -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||||
|
|
||||||
|
- name: Extract Tag
|
||||||
|
id: tag
|
||||||
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build Image
|
||||||
|
run: docker build -t gitea.johannesbot.de/johannesbot/stupid-apis:${{ steps.tag.outputs.VERSION }} .
|
||||||
|
|
||||||
|
- name: Push Image
|
||||||
|
run: docker push gitea.johannesbot.de/johannesbot/stupid-apis:${{ steps.tag.outputs.VERSION }}
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,3 +2,5 @@ node_modules
|
|||||||
test.*
|
test.*
|
||||||
*.log
|
*.log
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
package-lock.json
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Basis-Image
|
# Basis-Image
|
||||||
FROM node:20
|
FROM node:24.14
|
||||||
|
|
||||||
# Arbeitsverzeichnis
|
# Arbeitsverzeichnis
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
158
doc/api.md
158
doc/api.md
@@ -1,158 +0,0 @@
|
|||||||
|
|
||||||
# 📄 API Documentation – **Stupid APIs**
|
|
||||||
|
|
||||||
## Base URL
|
|
||||||
|
|
||||||
```
|
|
||||||
http://localhost:3000/api
|
|
||||||
```
|
|
||||||
|
|
||||||
**Default Headers:**
|
|
||||||
|
|
||||||
```
|
|
||||||
Content-Type: application/json
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## POST `/sort`
|
|
||||||
|
|
||||||
Sorts an array (numeric or alphabetical) and returns the sorted array.
|
|
||||||
|
|
||||||
### Request
|
|
||||||
|
|
||||||
**URL:**
|
|
||||||
|
|
||||||
```
|
|
||||||
POST /sort
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
**Body Example:**
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"input": [3, 1, 4, 1, 5, 9]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Successful Response
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"sortedArray": [1, 1, 3, 4, 5, 9]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## POST `/isOdd`
|
|
||||||
|
|
||||||
Checks if a given number is odd.
|
|
||||||
|
|
||||||
### Request
|
|
||||||
|
|
||||||
**URL:**
|
|
||||||
|
|
||||||
```
|
|
||||||
POST /isOdd
|
|
||||||
```
|
|
||||||
|
|
||||||
**Body Example:**
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"input": 7
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Successful Response
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"ret": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## POST `/isEven`
|
|
||||||
|
|
||||||
Checks if a given number is even.
|
|
||||||
|
|
||||||
### Request
|
|
||||||
|
|
||||||
**URL:**
|
|
||||||
|
|
||||||
```
|
|
||||||
POST /isEven
|
|
||||||
```
|
|
||||||
|
|
||||||
**Body Example:**
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"input": 4
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Successful Response
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"ret": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## POST `/toString`
|
|
||||||
|
|
||||||
calls .toString()
|
|
||||||
|
|
||||||
### Request
|
|
||||||
|
|
||||||
**URL:**
|
|
||||||
|
|
||||||
```
|
|
||||||
POST /toString
|
|
||||||
```
|
|
||||||
|
|
||||||
**Body Example:**
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"input": 7
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Successful Response
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"ret": "7"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📌 Example Usage with `curl`
|
|
||||||
|
|
||||||
### Sort an array (Linux/macOS)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:3000/sort \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"array":[3,1,4,1,5,9]}'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Check if odd
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:3000/is-odd \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"number":7}'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Check if even
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:3000/is-even \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"number":4}'
|
|
||||||
```
|
|
||||||
23
nginx.conf
23
nginx.conf
@@ -1,23 +0,0 @@
|
|||||||
events {}
|
|
||||||
|
|
||||||
http {
|
|
||||||
upstream stupid_apis {
|
|
||||||
server stupid-apis-1:3000;
|
|
||||||
server stupid-apis-2:3000;
|
|
||||||
server stupid-apis-3:3000;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://stupid_apis;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection 'upgrade';
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_cache_bypass $http_upgrade;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
1258
package-lock.json
generated
1258
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,11 @@
|
|||||||
"start": "node src/server.js"
|
"start": "node src/server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
|
||||||
"body-parser": "^1.20.2",
|
"body-parser": "^1.20.2",
|
||||||
|
"express": "^4.18.2",
|
||||||
"is-even": "^1.0.0",
|
"is-even": "^1.0.0",
|
||||||
"is-odd": "^3.0.1",
|
"is-odd": "^3.0.1",
|
||||||
"showdown": "^2.1.0",
|
"swagger-jsdoc": "^6.2.8",
|
||||||
"fs": "^0.0.1-security"
|
"swagger-ui-express": "^5.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/routes/api/add.js
Normal file
14
src/routes/api/add.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post('/', (req, res) => {
|
||||||
|
const { input } = req.body;
|
||||||
|
|
||||||
|
res.json({ ret: input.a + input.b });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/:a/:b', (req, res) => {
|
||||||
|
res.json({ ret: Number(req.params.a) + Number(req.params.b) });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
14
src/routes/api/divide.js
Normal file
14
src/routes/api/divide.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post('/', (req, res) => {
|
||||||
|
const { input } = req.body;
|
||||||
|
res.json({ ret: input.a / input.b });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/:a/:b', (req, res) => {
|
||||||
|
res.json({ ret: Number(req.params.a) / Number(req.params.b) });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
||||||
14
src/routes/api/multiply.js
Normal file
14
src/routes/api/multiply.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post('/', (req, res) => {
|
||||||
|
const { input } = req.body;
|
||||||
|
res.json({ ret: input.a * input.b });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/:a/:b', (req, res) => {
|
||||||
|
res.json({ ret: Number(req.params.a) * Number(req.params.b) });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ router.post('/', (req, res) => {
|
|||||||
return String(a).localeCompare(String(b));
|
return String(a).localeCompare(String(b));
|
||||||
});
|
});
|
||||||
|
|
||||||
res.json({ sortedArray });
|
res.json({ ret: sortedArray });
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
29
src/routes/api/stalinSort.js
Normal file
29
src/routes/api/stalinSort.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post('/', (req, res) => {
|
||||||
|
const { input } = req.body;
|
||||||
|
|
||||||
|
if (!Array.isArray(input)) {
|
||||||
|
return res.status(400).json({ error: 'Request body muss ein Feld "array" mit einem Array enthalten' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortedArray = Array();
|
||||||
|
sortedArray.push(input[0]);
|
||||||
|
let executions = 0;
|
||||||
|
|
||||||
|
for (let i = 1; i < input.length; i++) {
|
||||||
|
if (input[i] > input[i - 1]) {
|
||||||
|
sortedArray.push(input[i]);
|
||||||
|
} else {
|
||||||
|
executions++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
ret: sortedArray,
|
||||||
|
executions
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
14
src/routes/api/subtract.js
Normal file
14
src/routes/api/subtract.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post('/', (req, res) => {
|
||||||
|
const { input } = req.body;
|
||||||
|
res.json({ ret: input.a - input.b });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/:a/:b', (req, res) => {
|
||||||
|
res.json({ ret: Number(req.params.a) - Number(req.params.b) });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
||||||
@@ -1,41 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const showdown = require('showdown');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const converter = new showdown.Converter({
|
|
||||||
tables: true, // Tabellen-Unterstützung aktivieren
|
|
||||||
ghCompatibleHeaderId: true,
|
|
||||||
simpleLineBreaks: true,
|
|
||||||
emoji: true
|
|
||||||
});
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const swaggerUi = require('swagger-ui-express');
|
||||||
|
const openAPI = require('./openapi.json');
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.use('/', swaggerUi.serve);
|
||||||
const filePath = path.join(__dirname, '../../../doc/api.md');
|
router.get('/', swaggerUi.setup(openAPI));
|
||||||
|
|
||||||
fs.readFile(filePath, 'utf-8', (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).send("Fehler beim Laden der Markdown-Datei");
|
|
||||||
}
|
|
||||||
|
|
||||||
const htmlContent = converter.makeHtml(data);
|
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
|
||||||
res.send(`<!doctype html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>API-Dokumentation</title>
|
|
||||||
<link rel="stylesheet" href="/css/markdown-dark.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main class="markdown-body">
|
|
||||||
${htmlContent}
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
552
src/routes/docs/openapi.json
Normal file
552
src/routes/docs/openapi.json
Normal file
@@ -0,0 +1,552 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.0.0",
|
||||||
|
"info": {
|
||||||
|
"title": "Stupid APIs",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "API Documentation for Stupid APIs"
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "/api",
|
||||||
|
"description": "Current host server"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://localhost:3000/api",
|
||||||
|
"description": "Local server"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/sort": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Sorts an array",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {},
|
||||||
|
"example": [3, 1, 4, 1, 5, 9]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Sorted array",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"ret": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/stalinSort": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Sorts an array using Stalin Sort",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {},
|
||||||
|
"example": [3, 1, 4, 1, 5, 9]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Sorted array and execution count",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"ret": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {}
|
||||||
|
},
|
||||||
|
"executions": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isEven": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Checks if number is even",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isEven/{number}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Checks if number is even",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "number",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isOdd": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Checks if number is odd",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isOdd/{number}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Checks if number is odd",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "number",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isNumber": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Checks if input is a number",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/isNumber/{number}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Checks if param is a number",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "number",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/toString": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Converts input to string",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/stringSplit": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Splits a string",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"string": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"seperator": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/add": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Adds two numbers",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 5
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/add/{a}/{b}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Adds two numbers from path parameters",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/subtract": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Subtracts second number from first",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 10
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/subtract/{a}/{b}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Subtracts second number from first from path parameters",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "5"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/multiply": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Multiplies two numbers",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 5
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/multiply/{a}/{b}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Multiplies two numbers from path parameters",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/divide": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Divides first number by second",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 10
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/divide/{a}/{b}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Divides first number by second from path parameters",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": "2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,18 @@ const express = require('express');
|
|||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const sortRoute = require('./routes/api/sort');
|
const sortRoute = require('./routes/api/sort');
|
||||||
|
const stalinSortRoute = require('./routes/api/stalinSort');
|
||||||
const isEvenRoute = require('./routes/api/isEven');
|
const isEvenRoute = require('./routes/api/isEven');
|
||||||
const isOddRoute = require('./routes/api/isOdd');
|
const isOddRoute = require('./routes/api/isOdd');
|
||||||
const toStringRoute = require('./routes/api/toString');
|
const toStringRoute = require('./routes/api/toString');
|
||||||
const isNumberRoute = require('./routes/api/isNumber');
|
const isNumberRoute = require('./routes/api/isNumber');
|
||||||
const stringSplitRoute = require('./routes/api/stringSplit');
|
const stringSplitRoute = require('./routes/api/stringSplit');
|
||||||
|
const addRoute = require('./routes/api/add');
|
||||||
|
const subtractRoute = require('./routes/api/subtract');
|
||||||
|
const multiplyRoute = require('./routes/api/multiply');
|
||||||
|
const divideRoute = require('./routes/api/divide');
|
||||||
|
|
||||||
|
|
||||||
const docsRoute = require('./routes/docs/main');
|
const docsRoute = require('./routes/docs/main');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
@@ -17,11 +24,18 @@ app.use(express.static(path.join(__dirname, '../www')));
|
|||||||
|
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use('/api/sort', sortRoute);
|
app.use('/api/sort', sortRoute);
|
||||||
|
app.use('/api/stalinSort', stalinSortRoute);
|
||||||
app.use('/api/isEven', isEvenRoute);
|
app.use('/api/isEven', isEvenRoute);
|
||||||
app.use('/api/isOdd', isOddRoute);
|
app.use('/api/isOdd', isOddRoute);
|
||||||
app.use('/api/toString', toStringRoute);
|
app.use('/api/toString', toStringRoute);
|
||||||
app.use('/api/isNumber', isNumberRoute);
|
app.use('/api/isNumber', isNumberRoute);
|
||||||
app.use('/api/stringSplit', stringSplitRoute);
|
app.use('/api/stringSplit', stringSplitRoute);
|
||||||
|
app.use('/api/add', addRoute);
|
||||||
|
app.use('/api/subtract', subtractRoute);
|
||||||
|
app.use('/api/multiply', multiplyRoute);
|
||||||
|
app.use('/api/divide', divideRoute);
|
||||||
|
|
||||||
|
|
||||||
app.use('/docs', docsRoute);
|
app.use('/docs', docsRoute);
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
|
|||||||
@@ -1,194 +0,0 @@
|
|||||||
/* markdown-dark.css */
|
|
||||||
/* Basis: neutraler Dark-Mode mit guter Lesbarkeit und sauberem Tabellenlayout */
|
|
||||||
:root {
|
|
||||||
--bg: #0d1117;
|
|
||||||
--bg-muted: #161b22;
|
|
||||||
--text: #c9d1d9;
|
|
||||||
--text-muted: #8b949e;
|
|
||||||
--border: #30363d;
|
|
||||||
--link: #58a6ff;
|
|
||||||
--code-bg: #161b22;
|
|
||||||
--code-text: #f0f6fc;
|
|
||||||
--kbd-bg: #0b1020;
|
|
||||||
--kbd-border: #30363d;
|
|
||||||
--accent: #1f6feb;
|
|
||||||
}
|
|
||||||
|
|
||||||
html, body {
|
|
||||||
background: var(--bg);
|
|
||||||
color: var(--text);
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-body {
|
|
||||||
box-sizing: border-box;
|
|
||||||
max-width: 900px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 24px;
|
|
||||||
line-height: 1.65;
|
|
||||||
font: 16px/1.65 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Überschriften */
|
|
||||||
.markdown-body h1,
|
|
||||||
.markdown-body h2,
|
|
||||||
.markdown-body h3,
|
|
||||||
.markdown-body h4,
|
|
||||||
.markdown-body h5,
|
|
||||||
.markdown-body h6 {
|
|
||||||
color: var(--text);
|
|
||||||
margin: 1.6em 0 .6em;
|
|
||||||
font-weight: 700;
|
|
||||||
line-height: 1.25;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
padding-bottom: .3em;
|
|
||||||
}
|
|
||||||
.markdown-body h1 { font-size: 2rem; }
|
|
||||||
.markdown-body h2 { font-size: 1.6rem; }
|
|
||||||
.markdown-body h3 { font-size: 1.35rem; border-bottom: none; }
|
|
||||||
.markdown-body h4 { font-size: 1.15rem; border-bottom: none; }
|
|
||||||
.markdown-body h5 { font-size: 1rem; border-bottom: none; }
|
|
||||||
.markdown-body h6 { font-size: .95rem; color: var(--text-muted); border-bottom: none; }
|
|
||||||
|
|
||||||
/* Text & Links */
|
|
||||||
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre, .markdown-body table {
|
|
||||||
margin: 1em 0;
|
|
||||||
}
|
|
||||||
.markdown-body a {
|
|
||||||
color: var(--link);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.markdown-body a:hover, .markdown-body a:focus {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Listen */
|
|
||||||
.markdown-body ul, .markdown-body ol {
|
|
||||||
padding-left: 1.5em;
|
|
||||||
}
|
|
||||||
.markdown-body li + li {
|
|
||||||
margin-top: .25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Code */
|
|
||||||
.markdown-body code,
|
|
||||||
.markdown-body tt {
|
|
||||||
background: var(--code-bg);
|
|
||||||
color: var(--code-text);
|
|
||||||
padding: .15em .35em;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
|
||||||
font-size: .95em;
|
|
||||||
}
|
|
||||||
.markdown-body pre {
|
|
||||||
background: var(--code-bg);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
.markdown-body pre code {
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
padding: 0;
|
|
||||||
color: var(--text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Blockquote */
|
|
||||||
.markdown-body blockquote {
|
|
||||||
border-left: 4px solid var(--border);
|
|
||||||
padding: .5em 1em;
|
|
||||||
margin-left: 0;
|
|
||||||
color: var(--text-muted);
|
|
||||||
background: rgba(22,27,34,.35);
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tabellen – wichtig für sauberes Layout */
|
|
||||||
.markdown-body table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border-spacing: 0;
|
|
||||||
overflow: auto;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.markdown-body thead {
|
|
||||||
background: var(--bg-muted);
|
|
||||||
}
|
|
||||||
.markdown-body th, .markdown-body td {
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
padding: 8px 12px;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.markdown-body th {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.markdown-body tr:nth-child(even) td {
|
|
||||||
background: rgba(22,27,34,.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HR */
|
|
||||||
.markdown-body hr {
|
|
||||||
height: 1px;
|
|
||||||
border: 0;
|
|
||||||
background: var(--border);
|
|
||||||
margin: 2em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bilder */
|
|
||||||
.markdown-body img {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Details/Summary */
|
|
||||||
.markdown-body details {
|
|
||||||
background: var(--bg-muted);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: .6em .9em;
|
|
||||||
}
|
|
||||||
.markdown-body summary {
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Markierung, KBD */
|
|
||||||
.markdown-body mark {
|
|
||||||
background: #99700066;
|
|
||||||
color: var(--text);
|
|
||||||
padding: 0 .2em;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
.markdown-body kbd {
|
|
||||||
background: var(--kbd-bg);
|
|
||||||
border: 1px solid var(--kbd-border);
|
|
||||||
border-bottom-width: 2px;
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: .1em .4em;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
||||||
font-size: .85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Zitate/Callouts (Admonitions via blockquote) */
|
|
||||||
.markdown-body blockquote > :first-child { margin-top: 0; }
|
|
||||||
.markdown-body blockquote > :last-child { margin-bottom: 0; }
|
|
||||||
|
|
||||||
/* Inline-Abstände */
|
|
||||||
.markdown-body strong { color: var(--text); }
|
|
||||||
.markdown-body em { color: var(--text); }
|
|
||||||
|
|
||||||
/* Code-Block Scrollbar etwas dezenter */
|
|
||||||
.markdown-body pre::-webkit-scrollbar,
|
|
||||||
.markdown-body table::-webkit-scrollbar {
|
|
||||||
height: 10px;
|
|
||||||
}
|
|
||||||
.markdown-body pre::-webkit-scrollbar-thumb,
|
|
||||||
.markdown-body table::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--border);
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user