-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
163 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
## API | ||
```http | ||
GET /api/conf | ||
``` | ||
Get app config | ||
|
||
|
||
```http | ||
GET /api/exec?name=NAME&type=TYPE&exec=EXEC | ||
``` | ||
Execute a command, where | ||
- `NAME` - Item name | ||
- `TYPE` - Item Type | ||
- `EXEC` - one of the commands: Start, Stop, Restart, Logs, State | ||
|
||
Returns: | ||
- `Ok` - `true` or, if error occurred `false` | ||
- `Out` - command output | ||
|
||
<details> | ||
<summary>Example</summary> | ||
|
||
```sh | ||
curl "http://0.0.0.0:8855/api/exec?name=wyl&type=Docker&exec=Start" | ||
``` | ||
```json | ||
{ | ||
"Ok": true, | ||
"Out": "wyl\n" | ||
}⏎ | ||
``` | ||
|
||
</details> | ||
<br> | ||
|
||
```http | ||
GET /api/items | ||
``` | ||
Get all Items with their current states | ||
|
||
```http | ||
GET /api/types | ||
``` | ||
Get all Types | ||
|
||
```http | ||
POST /api/conf | ||
``` | ||
Save config variable `conf`. Example: `data.set('conf', JSON.stringify(conf))` | ||
```http | ||
POST /api/item | ||
``` | ||
Edit Item. Variables: | ||
- `old` - old Item | ||
- `new` - new Item (empty Name to delete Item) | ||
```http | ||
POST /api/type | ||
``` | ||
Edit Type. Variables: | ||
- `old` - old Type | ||
- `new` - new Type (empty Name to delete Type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# For developers | ||
|
||
This app has separate frontend (`React`) and backend (`Go`). You need to run both of them to see modifications while editing the code. | ||
|
||
## Dev | ||
|
||
1. Backend | ||
```sh | ||
cd backend/ # | ||
make check # check golang code | ||
make run # run backend | ||
``` | ||
The backend needs to be restarted to apply any modifications to it! | ||
|
||
2. Frontend | ||
```sh | ||
cd frontend/ | ||
npm i # install node modules | ||
npm run dev # run frontend | ||
``` | ||
Make sure the `api` port in `frontend/src/functions/api.tsx` is the same the backend uses. | ||
|
||
## Build | ||
To build the app in a single file, there is a `frontend/Makefile`: | ||
```sh | ||
cd frontend/ | ||
make all | ||
``` | ||
Edit the `api` port in the Makefile if needed. | ||
|
||
Then I just push the code to Github and let Actions build Docker and Binary files for me=) | ||
|
||
### Build locally | ||
To build binary locally, after the steps above, run: | ||
|
||
```sh | ||
cd backend/ | ||
make go-build | ||
``` | ||
Binary file will be in `backend/tmp/AnyAppStart` |