The backend for getcovidhelp.in
The backend was built using Nodejs and deployed on cloudflare workers. It uses cloudflare workers kv as its database.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Create a cloudflare account. Free tier works too.
- Create a kv namespace. This will be needed later
- Install Wrangler
npm i @cloudflare/wrangler -g
- Login to your cloudflare account
wrangler login
- Clone this repo
git clone https://github.com/getcovidhelpindia/cloudflare_workers.git
- Create a
wrangler.toml
file in the root directory. Then add the corresponding account id and namespace ids in thewrangler.toml
. - To run it locally, run
wrangler dev
- Try pushing data to your kv using postman
API endpoint
<LOCALHOST>/addData
Sample body
{
"state":"Bihar",
"district":"Arwal",
"type":"0",
"info":{
"name":"Jhumri Teliya",
"contact":"123456789",
"description":"Oxygen supplier",
"location":"Arwal"
},
"source":"zyx data",
"createdAt":"2021-04-22T02:24:07.962Z",
"isApproved":true,
"isFlagged":false,
"Usefulness":0,
"isHidden":false,
"key":"bihar_arwal_hanwk1bchhxnn6fn"
}
P.S- Add body as raw text in postman. Form data does not work currently.
To deploy to your worker, run wrangler publish
- Cloudflare Workers - Serverless solution
- Cloudflare Workers KV - Database
- NodeJs - Server Environment
- Chinmay Kabi - Initial developer
- Huge inspiration covid19india.org