An open API service indexing awesome lists of open source software.

https://github.com/flume-cloud-services/database

Golang Database via HTTP using LevelDB (by Flume Cloud Services)
https://github.com/flume-cloud-services/database

cloud database firestore golang http http-server json self-hosted

Last synced: 3 months ago
JSON representation

Golang Database via HTTP using LevelDB (by Flume Cloud Services)

Awesome Lists containing this project

README

          




# Database
`Golang Database` via **HTTP** using *LevelDB* and *GJSON & SJSON* (by Flume Cloud Services)

## Installation

### Docker

```bash
docker run -d -p 8080:8080 flumecloudservices/database
```

### Manually

```bash
mkdir $GOPATH/src/github.com/flume-cloud-services && cd $GOPATH/src/github.com/flume-cloud-services
git clone https://github.com/flume-cloud-services/database.git && cd database
go get -d -v
go install -v

FLUME_DATABASE_ADMIN=admin_name FLUME_DATABASE_SECRET=secret_token database
```

## Usage

Use the `signin` route with the following body to generate the JWT token :

```
POST /signin

Body:
- username: The admin name given in FLUME_DATABASE_ADMIN by default it's simply "admin"

Return:
- If success :
- A JWT Token
- The cookie with the previously generated JWT Token
- If failed :
- Unauthorized Status
- Bad request Status
```

Check if the jwt is correctly generated by visiting `welcome` route :

```
GET /welcome

Return:
- If success :
- Welcome to you visitor !
-If failed :
- Unauthorized Status
```

Then create a database using the `/database/create` route :

```
POST /database/create

Body:
- name: The database name

Return:
- If success :
- Database succesfully created
- If failed :
- Bad Request Status
- Internal Server Error Status
```

You can delete the previously created database using the `database/delete` route :

```
POST /database/delete

Body:
- name: The database name

Return:
- If success :
- Database succesfully deleted
- If failed :
- Bad Request Status
- Internal Server Error Status
```

Then you have to insert data into a specific table using [SJSON](https://github.com/tidwall/sjson) (I recommend you to know the basics of [GJSON Syntax](https://github.com/tidwall/gjson#path-syntax)) and the route `/insert` :

```
POST /insert

Body:
- database: The database name
- query: The GJSON query
- content: The JSON stringified content of the table

Return:
- If success :
- Data successfully inserted into table
- If failed :
- Bad Request Status
- Internal Server Error Status
```

Now you can query your database using [GJSON](https://github.com/tidwall/gjson) (I recommend you to know the basics of [GJSON Syntax](https://github.com/tidwall/gjson#path-syntax)) and the `/query` route :

```
POST /query

Body:
- name: The database name
- query: The GJSON query

Return:
- If success :
- The response of the given query
- If failed :
- Bad Request Status
- Internal Server Error Status
```

### Example of Query

Query : `table.0.key`

Give the specified key into the specified table at the index '0'

### Example of Insert

Query : `table.0.key`
Content : `Key Content`

Set the specified content into the specified key into the specified table at the index '0'

### Dashboard

You can access the dashboard here `/dash` by giving the admin name and the secret.