Logo Lanfrica

africa-covid-19-response-toolkit/api

Domaine:

healthcare

Type de record:

software
Créateur:
afr
Hôte:
# API for writing/retrieving COVID-19 data This API will be utilised by all applications that need to write/retrieve Ethiopia Covid19 data. E.g. covid19.et project will use it to retrieve data for dashboard and write data ## Serverless REST API This example demonstrates how to setup a RESTful Web Services allowing you to create, list, get, update and delete Community. DynamoDB is used to store the data. This is just an example and of course you could use any data storage as a backend. ## Structure This service has a separate directory for all the community operations. For each operation exactly one file exists e.g. `handler/delete.js`. In each of these files there is exactly one function which is directly attached to `module.exports`. The idea behind the `communities` directory is that in case you want to create a service containing multiple resources e.g. users, notes, comments you could do so in the same service. While this is certainly possible you might consider creating a separate service for each resource. It depends on the use-case and your preference. ### Use-cases - API for a Web Application - API for a Mobile Application ### Setup ```bash npm install # To run locally # ---- # Install MongoDB brew install mongodb # Start MongoDB daemon (keep this running) mongod --dbpath mongo-db # In a new terminal npm run dev ``` ### Debug In VSCODE: Activity Bar > Run > sls debug OR a shortcut is F5 ### Deploy In order to deploy the endpoint simply run ```bash serverless deploy ``` ## Testing ```bash npm test ``` API Documentation documenter.getpostman.com --- ## Auth Flow ``` client_id = {value} client_secret = {value} ``` Ping @Naod on Slack to get the values above Generate base64 key by using the `client_id` and `client_secret` ``` $ echo -n 'client_id:client_secret' | openssl base64 Node example: const AUTHORIZATION_KEY = Buffer.from('process.env.CLIENT_ID:process.env.CLIENT_SECRET').toString(' …