5
0
Fork 0
backend-bite/README.md

119 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2019-01-26 00:36:21 +08:00
# backend-bite
2019-02-08 07:30:21 +08:00
Beep backend handling of audio bites. Chopped up words spoken are uploaded into bite to be stored in a scan-able key-value store. Subscribes to ```new_bite``` and ```new_bite_user``` events from a NATS publisher.
## Quickstart
```
go build && ./backend-bite
```
2019-02-18 23:42:49 +08:00
## Environment Variables
2019-02-08 07:30:21 +08:00
2019-02-18 23:42:49 +08:00
Supply environment variables by either exporting them or editing ```.env```.
2019-02-08 07:30:21 +08:00
2019-02-18 23:42:49 +08:00
| ENV | Description | Default |
2019-02-08 07:30:21 +08:00
| ---- | ----------- | ------- |
2019-02-18 23:42:49 +08:00
| LISTEN | Host and port number to listen on | :8080 |
| NATS | Host and port of nats | nats://localhost:4222 |
2019-02-08 07:30:21 +08:00
## API
### Scan Bites
```
GET /conversation/:key/scan
```
2019-02-08 07:50:10 +08:00
Get a list of bite start times within a conversation key and specified timespan.
#### URL Params
| Name | Type | Description |
| ---- | ---- | ----------- |
| key | String | Audio bite's conversation's ID. |
#### Querystring
| Name | Type | Description |
| ---- | ---- | ----------- |
| from | Epoch timestamp | Time to start scanning from |
| to | Epoch timestamp | Time to scan to |
#### Success (200 OK)
```
Content-Type: application/json
```
```
{
"previous": <Timestamp of bite before <starts>>,
"starts": [Timestamp, Timestamp...],
"next": <Timestamp of bite after <starts>>,
}
```
#### Errors
| Code | Description |
| ---- | ----------- |
| 400 | Malformed input (from/to not timestamp, key not alphanumeric). |
| 500 | NATs or protobuf serilisation encountered errors. |
2019-02-08 07:50:10 +08:00
---
2019-02-08 07:30:21 +08:00
### Get Bite
```
GET /conversation/:key/start/:start
```
2019-02-08 07:50:10 +08:00
Get a specific ```bite```.
#### URL Params
| Name | Type | Description |
| ---- | ---- | ----------- |
| key | String | Audio bite's conversation's ID. |
| start | Epoch timestamp | Time the audio bite starts. |
#### Success (200 OK)
Raw audio data.
#### Errors
| Code | Description |
| ---- | ----------- |
| 400 | start is not an uint/key is not an alphanumeric string/specified bite could not be found |
| 500 | NATs or protobuf serilisation encountered errors. |
2019-02-08 07:50:10 +08:00
---
2019-02-08 07:30:21 +08:00
### Get Bite User
```
GET /conversation/:key/start/:start/user
```
2019-02-08 07:50:10 +08:00
Get a specific ```bite_user```.
#### URL Params
| Name | Type | Description |
| ---- | ---- | ----------- |
| key | String | Audio bite's conversation's ID. |
| start | Epoch timestamp | Time the audio bite starts. |
#### Success (200 OK)
Raw audio data.
#### Errors
| Code | Description |
| ---- | ----------- |
| 400 | start is not an uint/key is not an alphanumeric string/specified bite could not be found |
| 500 | NATs or protobuf serilisation encountered errors. |