Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/sdslabs/zap-db

An easy to use JSON database written with ease of setup and memory management of slack bots in mind.
https://github.com/sdslabs/zap-db

bots database db json typescript

Last synced: about 1 month ago
JSON representation

An easy to use JSON database written with ease of setup and memory management of slack bots in mind.

Awesome Lists containing this project

README

        

# zap-db

An easy to use JSON database written with ease of setup and memory management of slack bots in mind.

[![CI](https://github.com/sdslabs/zap-db/actions/workflows/ci.yml/badge.svg)](https://github.com/sdslabs/zap-db/actions/workflows/ci.yml) [![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs) [![Discord](https://discordapp.com/api/guilds/758961084337618944/embed.png)](https://discord.gg/dXkVEgTPu9)

## Concept

1. There's an admin for the database server, only who can
create new JSON databases.

2. On creating a new database, the user will receive a token
which can be used to make requests to the database server.
This user is called the `owner` and there can only be one
owner of a JSON database.

3. An owner can later on create more tokens with varying
scopes which are `read`, `write`, and `delete`. These
child tokens can have any combination of the aforementioned
scopes. These can be created in any number of amounts,
yet access to them can be revoked by the db owner.

4. Ofcourse, admin can also revoke owner's access to the
database and can delete the db as well. It's just common
courtesy to send the backup of the database to the owner
before demolishing it.

5. Each request should be made with a token in headers of
the request. More precisely, the `Authorization` header.
The token contains the database information and hence,
there is no need to specify the db in routes.

6. Routes should contain the basic `GET /` and `POST /` for
reading and writing, along-with `DELETE /` for deleting
the database but should also contain `PATCH /` for patch
updates. In case of patch, only the JSON specified in the
request body is updated.

For example:
```json
{
"name": "Thanos",
"work": "Destroy 50% of the universe",
}
```
In the above case, a request with the body:
```json
{
"work": "Save 50% of the universe"
}
```
Should just update the `work` part of the JSON.

## Development

1. Clone the repository and `cd` to it.

1. Install dependencies:
```shell
$ npm install
```

1. Copy the `sample.config.json` as `config.json` and make
required changes:
```shell
$ cp sample.config.json config.json
```

1. Password in config is the sha256 of the password you want
to keep for the admin. Use the following command to hash:
```shell
$ npm run hash

Input your password:
> ...
ab5df625bc76dbd4e163bed2dd888df828f90159bb93556525c31821b6541d46
```

1. Run the server in watch mode (reloads on file change):
```shell
$ npm run watch
```

1. Run `npm run format` to format auto-fixable errors.

1. Run `npm run lint` to check for linting errors.

Postman Collection : https://www.getpostman.com/collections/9135694a2a9a2410d3ae

## Got Questions?

Hop in to our Discord Server if you have any questions or if you'd like to contribute to the project

## License

This project is under the MIT license. See NOTICE for thirdparty license notices.