mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
i did a lot of work, and i also forgot to add commits regularly. I added the controller routes to create and delete controllers, improved error handling und improved the authentification process. I'm gonna add an websocket next and then I should be hopefully done with the foundations of this project. I may also add anviewControllers route which respons with every available controller
66 lines
2.0 KiB
Markdown
66 lines
2.0 KiB
Markdown
# 🛋️ Laterna (Server)
|
||
|
||
## 🛜 API Documentation
|
||
|
||
### Base URL
|
||
`http://your-server.com/api/v1`
|
||
|
||
---
|
||
### Authentification
|
||
The admin token will be displayed once while starting for the first time. To generate a new one, run with the `--resetAdminToken` flag.
|
||
|
||
All endpoints require the admin token in the header of the request:
|
||
```
|
||
Authorization: <token>
|
||
```
|
||
|
||
---
|
||
|
||
### Routes
|
||
|
||
#### Controller
|
||
| Method | Route | Description | Request Body |
|
||
|---------|----------------------------|----------------------------------------|----------------------------------|
|
||
| POST | `/controllers` | Create a new controller | — |
|
||
| DELETE | `/controllers` | Delete an existing controller |`{ "ID": 1 }` |
|
||
|
||
---
|
||
|
||
#### Colors
|
||
| Method | Route | Description | Request Body |
|
||
|---------|----------------------------|----------------------------------------|----------------------------------|
|
||
| GET | `/colors/{id}` | Get the current color of an controller | — |
|
||
| PUT | `/colors/{id}` | Set the color of an controller |`{ "color": "#FF0000" }` |
|
||
|
||
---
|
||
|
||
### cURL examples
|
||
|
||
|
||
#### Create a new controller
|
||
```bash
|
||
$ curl -X POST http://your-server.com/api/v1/controllers \
|
||
-H "Authorization: $TOKEN"
|
||
```
|
||
ℹ️ Response with the newly assigned ID. The ID will always be the next available one
|
||
|
||
#### Delete an controller
|
||
```bash
|
||
$ curl -X DELETE localhost:8080/api/v1/controllers \
|
||
-H "Authorization: $TOKEN" \
|
||
-d '{"ID": 1}'
|
||
```
|
||
|
||
|
||
#### Get the current color of an controller
|
||
```bash
|
||
$ curl -X GET localhost:8080/api/v1/colors/1 \
|
||
-H "Authorization: $TOKEN"
|
||
```
|
||
#### Set the color of an controller
|
||
```bash
|
||
$ curl -X PUT localhost:8080/api/v1/colors/1 \
|
||
-H "Authorization:$TOKEN" \
|
||
-d '{"Color": "#C2C342"}'
|
||
```
|