Skip to content

Latest commit

 

History

History
141 lines (114 loc) · 4.08 KB

README.md

File metadata and controls

141 lines (114 loc) · 4.08 KB

Sandbox Backend for Assignment

Description

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

Prerequisites

Before getting started, make sure you have Node 18+ installed. You can download it from the official Node.js site here.

Installation

To get started, follow these steps:

  1. Clone the repository:
git clone https://github.com/practicehealth/assignment-sandbox-backend.git
  1. Install the dependencies:
npm install
  1. Start the server:
npm start

Usage

The server will be running on http://localhost:3000. You can use the following endpoints:

Login

  • Method: POST
  • Path: /auth/login
  • Description: This route is used to login the user and generate access token and refresh token
  • Body:

Token

  • Method: GET
  • Path: /auth/token
  • Description: This route is used to generate new access token using refresh token

Logout

  • Method: POST
  • Path: /auth/logout
  • Description: This route is used to logout the user and clear the refresh token

Visits

  • Method: GET
  • Path: /visits
  • Description: This route is used to get all the visits for creating the timeline component
  • Headers:
    • Authorization: Bearer

Complete task

  • 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)

Categories - Medication

  • Method: GET
  • Path: /categories/medication
  • Description: This route is used to get all the categories of type medication
  • Headers:
    • Authorization: Bearer

Categories - Labs

  • Method: GET
  • Path: /categories/labs
  • Description: This route is used to get all the categories of type labs
  • Headers:
    • Authorization: Bearer

Categories - Vitals

  • Method: GET
  • Path: /categories/vitals
  • Description: This route is used to get all the categories of type vitals
  • Headers:
    • Authorization: Bearer

Categories - Immunization

  • Method: GET
  • Path: /categories/immunization
  • Description: This route is used to get all the categories of type immunization
  • Headers:
    • Authorization: Bearer

Categories - Condition

  • Method: GET
  • Path: /categories/condition
  • Description: This route is used to get all the categories of type condition
  • Headers:
    • Authorization: Bearer

Categories - Procedure

  • Method: GET
  • Path: /categories/procedure
  • Description: This route is used to get all the categories of type procedure
  • Headers:
    • Authorization: Bearer

Categories - Allergy

  • Method: GET
  • Path: /categories/allergy
  • Description: This route is used to get all the categories of type allergy
  • Headers:
    • Authorization: Bearer

Categories Info

  • 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

Resources

  • Method: GET
  • Path: /resources
  • Description: This route is used to get all the documents linked in the visit objects
  • Headers:
    • Authorization: Bearer

Notes:

  • 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.