Giter Club home page Giter Club logo

cloudflaredb's Introduction

whatsbot

The low latency database powered by Cloudflare Worker and KV



Features :

  • Globally Available
  • Lowest Latancy
  • Serverless
  • Rest API
  • Token Based Authenticated Request Support

API :

1. Save a Payload (JSON)

  • Request:
Method: POST
Content-Type: application/json
URL (Secured with Token): https://<your-app>.workers.dev/?key=<post-key>
URL (Not Secured): https://<your-app>.workers.dev/
BODY: Json Data (Not Parsed)
  • Response:
{
    "status": true,
    "_id": "16125252787azq",
    "query": "https://<your-app>.workers.dev/16125252787azq",
    "data": {
        "i_am": "writing a readme"
    }
}
  • Set an ID manually:
Send this ๐Ÿ‘‡

"_id":"my-unique-id"

with Body

2. Get a saved Data:

  • Request:
Method: GET
URL: https://<your-app>.workers.dev/<_id>
  • Response:
{
    "status": true,
    "_id": "16125252787azq",
    "data": {
        "i_am": "writing a readme"
    }
}

3. Delete a Data:

  • Request:
Method: DELETE
URL (Secured with Token): https://<your-app>.workers.dev/<_id>?key=<delete-key>
URL (Not Secured): https://<your-app>.workers.dev/<_id>
  • Response:
{
    "status": true,
    "msg": "Deleted Successfully"
}

Deploy :

  • Open Cloudflare Worker Page
  • Click on KV
  • In Namespace Name section Type a Name & Click on Add, a namespace will created.
  • Now click on Workers & Create a worker
  • Copy the code of worker.js , paste into Worker & Click on Save & Deploy
  • Now go back to worker main page, here you will see that your created worker listed there, click on that.
  • Click on Settings
  • In KV Namespace Bindings section click on Add Binding
  • Write TUHIN in Variable name & select your recently created Namespace for KV namespace.
  • You just made your Cloudflare DB, Now Read the API Endpoint and use it in your Project ๐Ÿ˜ช

Secure with Token :

You can impliment token based authentication system for POST and DELETE requests

  • Write your key in POSTKEY to secure POST requests with a Token (Line No: 12)
  • Write your key in DELETEKEY to secure DELETE requests with a Token (Line No: 13)

Note for Kangers :

Kanging will not make you a developer. So, don't be a kanger โš 

License & Copyright :

Connect :

Thanks to Cloudflare to give these services for free ๐Ÿฅฐ

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.