Skip to content

Latest commit

 

History

History

server

Patient Profile Management API Server

Table of Contents

Overview

Patient Profile Management is the api to keep the record of the patient record.

Development Setup

Prerequisites

Installation

1. Clone the repository and install dependencies.
$ git clone https://github.com/bibekthapa007/patient-profile-management.git
$ yarn
2. Copy .env.example as .env file inside your root directory. Update the environment variables based on stage.
$ cp .env.example .env
3. Run migration to sync the database state.
$ yarn migrate
4. Seed the database.
$ yarn seed

Development Workflow

Start the development server.

$ yarn start:dev

When you make unit of changes such as Creating API for updating status. Here are the steps someone must adhere to before commiting changes:

1. Lint your code.

$ yarn lint

2. Run the prettify on your source code for consistent formatting.

$ yarn prettier

3. Finally, commit your changes.

$ git commit -m "Commit" #duration <DURATION> <YOUR_COMMIT_MESSAGE>"

Continous deployment

There are multiple build targets available for different stages. These images can be used to deploy or run jobs in different container based cloud infrastructure like Kubernetes, AWS ECS, Fargate, GCP Cloud Run etc.

  1. Building a production image.

    $ docker build --target=prod -t app:prod .
  2. Building an image for development.

    $ docker build --target=dev -t app:dev .
  3. Building an image that runs migration and/or rollback.

     # Docker image that runs migration and seeds.
     $ docker build --target=migrate -t app:migrate .
    
     # Docker image that rollbacks migrations.
     $ docker build --target=migrate-rollback -t app:migrate-rollback .

Once the images have been built - all you need to do is run them providing a .env file. Like this:

$ docker run -v "/path/to/your/.env:/app/.env" app:migrate

Tests

To run the tests you need to create a separate test database. Don't forget to update your .env file to include the connections for test database.

$ NODE_ENV=test yarn migrate
$ yarn test

Run tests with coverage.

$ yarn test:coverage