This is a sandbox backend for the assignment. It is a simple REST API that allows you to do a simple login and fetch data for your flutter/react application
Before getting started, make sure you have Node 18+ installed. You can download it from the official Node.js site here.
To get started, follow these steps:
- Clone the repository:
git clone https://github.com/practicehealth/assignment-sandbox-backend.git
- Install the dependencies:
npm install
- Start the server:
npm start
The server will be running on http://localhost:3000
. You can use the following endpoints:
- Method: POST
- Path:
/auth/login
- Description: This route is used to login the user and generate access token and refresh token
- Body:
- email: string ("abdul@gmail.com" or "randal@gmail.com")
- Method: GET
- Path:
/auth/token
- Description: This route is used to generate new access token using refresh token
- Method: POST
- Path:
/auth/logout
- Description: This route is used to logout the user and clear the refresh token
- Method: GET
- Path:
/visits
- Description: This route is used to get all the visits for creating the timeline component
- Headers:
- Authorization: Bearer
- Method: POST
- Path:
/visits/task/complete
- Description: This route is used to complete the task in the timeline component
- Headers:
- Authorization: Bearer
- Body:
- taskId: string
- visitId: string
- note: string (optional)
- Method: GET
- Path:
/categories/medication
- Description: This route is used to get all the categories of type medication
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/labs
- Description: This route is used to get all the categories of type labs
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/vitals
- Description: This route is used to get all the categories of type vitals
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/immunization
- Description: This route is used to get all the categories of type immunization
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/condition
- Description: This route is used to get all the categories of type condition
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/procedure
- Description: This route is used to get all the categories of type procedure
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/allergy
- Description: This route is used to get all the categories of type allergy
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/categories/info
- Description: This route is used to get the information about the categories (please note this route is not a different category just a route to test how the response can come in the form of streams as well)
- Headers:
- Authorization: Bearer
- Method: GET
- Path:
/resources
- Description: This route is used to get all the documents linked in the visit objects
- Headers:
- Authorization: Bearer
- all routes for getting data are protected and require a valid access token to be passed in authorization header
- to get an accessToken you need to have a refresh token in your cookie which you can get by logging in
- currently only two users already exist in db with the following emails
abdul@gmail.com
randal@email.com
- there's no password
- to get data from a differnt user logout and login again with a different email
- To reset the data and start fresh just restart the server by killing the current process and writing
npm start
in the terminal again.