5
0
Fork 0
backend-publish/README.md

95 lines
2.2 KiB
Markdown
Raw Normal View History

2019-02-04 22:16:59 +08:00
# backend-publish
2019-02-10 22:17:24 +08:00
Beep backend accepts PUT requests and publishes a protobuf-ed version to a [NATS](htts://nats.io) queue, like some sort of weird HTTP/NATS converter. Also handles authentication of said HTTP requests. Needless to say, relies on a NATS instance being up.
2019-02-06 13:26:35 +08:00
2019-02-24 04:02:26 +08:00
**To run this service securely means to run it behind traefik forwarding auth to `backend-auth`**
2019-02-06 13:26:35 +08:00
## Quickstart
```
go build && ./backend-publish
```
2019-02-18 23:43:35 +08:00
## Environment Variables
2019-02-06 13:26:35 +08:00
2019-02-18 23:43:35 +08:00
Supply environment variables by either exporting them or editing ```.env```.
2019-02-06 13:26:35 +08:00
2019-02-18 23:43:35 +08:00
| ENV | Description | Default |
2019-02-06 13:26:35 +08:00
| ---- | ----------- | ------- |
2019-02-18 23:43:35 +08:00
| LISTEN | Host and port number to listen on | :8080 |
| NATS | Host and port of nats | nats://localhost:4222 |
| SECRET | JWT secret | secret |
2019-02-06 13:26:35 +08:00
## API
2019-02-24 04:02:26 +08:00
All requests need to be passed through `traefik` calling `backend-auth` as Forward Authentication. Otherwise, populate `X-User-Claim` with:
```json
{
"userid": "<userid>",
"clientid": "<clientid"
}
```
2019-02-10 22:17:24 +08:00
2019-02-06 13:26:35 +08:00
### Put Bite
```
PUT /conversation/:key/start/:start
```
TODO: Description of what this does cos honestly I have no idea Ambrose doesn't write documentation
#### URL Params
| Name | Type | Description |
| ---- | ---- | ----------- |
| key | String | Audio bite's conversation's ID. |
| start | Epoch timestamp | Time the audio bite starts. |
#### Body
Raw body of audio data in bytes.
#### Success (200 OK)
Empty body.
#### Errors
| Code | Description |
| ---- | ----------- |
2019-02-24 04:02:26 +08:00
| 400 | start is not an uint/key is not an alphanumeric string/data could not be read from the body/bad user claim |
2019-02-06 13:26:35 +08:00
| 500 | Error serialising data into a protocol buffer. |
---
### Put Bite User
```
PUT /conversation/:key/start/:start/user
```
TODO: Description of what this does cos honestly I have no idea Ambrose doesn't write documentation
#### URL Params
| Name | Type | Description |
| ---- | ---- | ----------- |
| key | String | Audio bite's conversation's ID. |
| start | Epoch timestamp | Time the audio bite starts. |
#### Body
Raw body of audio data in bytes.
#### Success (200 OK)
Empty body.
#### Errors
| Code | Description |
| ---- | ----------- |
2019-02-24 04:02:26 +08:00
| 400 | start is not an uint/key is not an alphanumeric string/data could not be read from the body/bad user claim |
2019-02-06 13:26:35 +08:00
| 500 | Error serialising data into a protocol buffer. |