An easy to use JSON database written with ease of setup and memory management of slack bots in mind.
MIT License
An easy to use JSON database written with ease of setup and memory management of slack bots in mind.
There's an admin for the database server, only who can create new JSON databases.
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.
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.
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.
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.
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:
{
"name": "Thanos",
"work": "Destroy 50% of the universe",
}
In the above case, a request with the body:
{
"work": "Save 50% of the universe"
}
Should just update the work
part of the JSON.
Clone the repository and cd
to it.
Install dependencies:
$ npm install
Copy the sample.config.json
as config.json
and make
required changes:
$ cp sample.config.json config.json
Password in config is the sha256 of the password you want to keep for the admin. Use the following command to hash:
$ npm run hash
Input your password:
> ...
ab5df625bc76dbd4e163bed2dd888df828f90159bb93556525c31821b6541d46
Run the server in watch mode (reloads on file change):
$ npm run watch
Run npm run format
to format auto-fixable errors.
Run npm run lint
to check for linting errors.
Postman Collection : https://www.getpostman.com/collections/9135694a2a9a2410d3ae
Hop in to our Discord Server if you have any questions or if you'd like to contribute to the project
This project is under the MIT license. See NOTICE for thirdparty license notices.