mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
docs: add setup instructions to README
This commit is contained in:
@@ -1,15 +1,27 @@
|
|||||||
# 🛋️ Laterna (Server)
|
# 🛋️ Laterna (Server)
|
||||||
|
|
||||||
|
## 🏵️ Setup
|
||||||
|
|
||||||
|
Laterna requires a config.json in it's root directory. An [example config](https://github.com/siestaw/Laterna/blob/main/config.json.example) is provided
|
||||||
|
|
||||||
|
`$ mv config.json.example config.json`
|
||||||
|
|
||||||
|
You can leave the json as it is or configure it to your liking, although some configuration options (e.g. `verboseLogging`) aren't fully implemented yet.
|
||||||
|
|
||||||
## 🛜 API Documentation
|
## 🛜 API Documentation
|
||||||
|
|
||||||
### Base URL
|
### Base URL
|
||||||
|
|
||||||
`http://your-server.com/api/v1`
|
`http://your-server.com/api/v1`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Authentification
|
### Authentification
|
||||||
|
|
||||||
The admin token will be displayed once while starting for the first time. To generate a new one, run with the `--resetAdminToken` flag.
|
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:
|
All endpoints require the admin token in the header of the request:
|
||||||
|
|
||||||
```
|
```
|
||||||
Authorization: <token>
|
Authorization: <token>
|
||||||
```
|
```
|
||||||
@@ -19,45 +31,51 @@ Authorization: <token>
|
|||||||
### Routes
|
### Routes
|
||||||
|
|
||||||
#### Controller
|
#### Controller
|
||||||
| Method | Route | Description | Request Body |
|
|
||||||
|---------|----------------------------|----------------------------------------|----------------------------------|
|
| Method | Route | Description | Request Body |
|
||||||
| POST | `/controllers` | Create a new controller | — |
|
| ------ | -------------- | ----------------------------- | ------------- |
|
||||||
| DELETE | `/controllers` | Delete an existing controller |`{ "ID": 1 }` |
|
| POST | `/controllers` | Create a new controller | — |
|
||||||
|
| DELETE | `/controllers` | Delete an existing controller | `{ "ID": 1 }` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### Colors
|
#### Colors
|
||||||
| Method | Route | Description | Request Body |
|
|
||||||
|---------|----------------------------|----------------------------------------|----------------------------------|
|
| 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" }` |
|
| GET | `/colors/{id}` | Get the current color of a controller | — |
|
||||||
|
| PUT | `/colors/{id}` | Set the color of a controller | `{ "color": "#FF0000" }` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### cURL examples
|
### cURL examples
|
||||||
|
|
||||||
|
|
||||||
#### Create a new controller
|
#### Create a new controller
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -X POST http://your-server.com/api/v1/controllers \
|
$ curl -X POST http://your-server.com/api/v1/controllers \
|
||||||
-H "Authorization: $TOKEN"
|
-H "Authorization: $TOKEN"
|
||||||
```
|
```
|
||||||
|
|
||||||
ℹ️ Response with the newly assigned ID. The ID will always be the next available one
|
ℹ️ Response with the newly assigned ID. The ID will always be the next available one
|
||||||
|
|
||||||
#### Delete an controller
|
#### Delete a controller
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -X DELETE localhost:8080/api/v1/controllers \
|
$ curl -X DELETE localhost:8080/api/v1/controllers \
|
||||||
-H "Authorization: $TOKEN" \
|
-H "Authorization: $TOKEN" \
|
||||||
-d '{"ID": 1}'
|
-d '{"ID": 1}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Get the current color of a controller
|
||||||
|
|
||||||
#### Get the current color of an controller
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -X GET localhost:8080/api/v1/colors/1 \
|
$ curl -X GET localhost:8080/api/v1/colors/1 \
|
||||||
-H "Authorization: $TOKEN"
|
-H "Authorization: $TOKEN"
|
||||||
```
|
```
|
||||||
#### Set the color of an controller
|
|
||||||
|
#### Set the color of a controller
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -X PUT localhost:8080/api/v1/colors/1 \
|
$ curl -X PUT localhost:8080/api/v1/colors/1 \
|
||||||
-H "Authorization:$TOKEN" \
|
-H "Authorization:$TOKEN" \
|
||||||
|
|||||||
Reference in New Issue
Block a user