Virtual Clinic User Service
Last updated 2 years ago by constant_jeff .
ISC · Original npm · Tarball · package.json
$ cnpm install virtual-clinic-user-service 
SYNC missed versions from official npm registry.

Virtual Clinic User Service


User service provides apis for user authorization and authentication. It provides token based authentication.

Responsibilities of the service:

  • Authentication and authorization
  • Issue and validate tokens (JWT)
  • Role management for access to resources
  • User Profile Management

There are multiple type of users in the system:

  • System Admins
  • Content Admins
  • Patients
  • Therapists
  • Clinic Manager


  • nodejs 8 (v8.11.3)
  • postgres 10
  • yarn
  • docker



Environment and configs

  1. Configs are in configs/ directory for all environments.
    • local.json (laptop or dev box)
    • test.json
    • prod.json etc
  2. set NODE_ENV=<env-name> environment variable while running server to load respective config file. e.g. NODE_ENV=prod npm start
  3. It has both db and app config values.
  4. App config is loaded by src/config.js and dbconfig by src/knex.js

Quick Setup

  1. Clone the repo
  2. yarn install. Visit Install yarn!
  3. Run NODE_ENV=local npm start-dev or yarn start-dev to start the app

Local postgres setup

  1. Create a user for local database access as below:
      createuser -P -s -e vc_db_user # Enter password as `vc_db_user`
      createdb user-service-dev -O vc_db_user
      createdb user-service-test -O vc_db_user
      psql -U vc_db_user user-service-dev -W
  2. To run container locally configure local ip in database connection in config file.

DB Migration and Seed data

  1. run latest migrations: NODE_ENV=local yarn knex migrate:latest
  2. setup seed data: NODE_ENV=local yarn knex seed:run
  3. rollback migrations: NODE_ENV=local yarn knex migrate:rollback

Running migrations on remote environments

Since database config is kept in SSM parameter store. it needs to downloaded before running knex migrations.

  • To fetch db config for an environment run yarn fetch-db-config task.
  • It will save database config in current directory as db-config.json
  • To run migrations use command below (runs fetch-db-config also):
  # fetch and save config in db-config.json and runs migrations
  NODE_ENV=tools yarn knex migrate:latest

Test and lint

  1. Run yarn test to run specs
  2. Run yarn lint to run es6 linter
  3. Run yarn all to run everything

Docker container

  1. Build the container locally using docker build -t user-service-v1 .
  2. Run the container using docker run -p 3003:3003 -d user-service-v1
  3. Open shell inside container: docker exec -it `docker ps | grep user-service-v1 | cut -f1 -d ' '` "/bin/sh"

Current Tags

  • 0.1.0                                ...           latest (2 years ago)

1 Versions

  • 0.1.0                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (29)
Dev Dependencies (20)
Dependents (0)

Copyright 2014 - 2016 © |