Skip to content
/ zap-db Public

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

License

Notifications You must be signed in to change notification settings

sdslabs/zap-db

Repository files navigation

zap-db

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

CI MIT License Discord

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:

    {
       "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.

Development

  1. Clone the repository and cd to it.

  2. Install dependencies:

    $ npm install
  3. Copy the sample.config.json as config.json and make required changes:

    $ cp sample.config.json config.json
  4. 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
  5. Run the server in watch mode (reloads on file change):

    $ npm run watch
  6. Run npm run format to format auto-fixable errors.

  7. 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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •