Giter VIP home page Giter VIP logo

zap-db's Introduction

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.

zap-db's People

Contributors

allmight2099 avatar ayanchoudhary avatar karan0299 avatar vrongmeal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.