Skip to content

Sunbird-VA/sunbird-va-data-service

Repository files navigation

Saarathi Data Service

Getting Started

Install dependencies:

npm install

Set environment (vars):

cp .env.example .env

Start server:

# Ensure that a PostgreSQL database is running on your localhost

# Start server
npm run start

Tests:

# Run tests written in ES6
yarn test

# Run test along with code coverage
yarn test:coverage

# Run tests on file change
yarn test:watch

Lint:

# Lint code with ESLint
yarn lint

# Run lint on any file change
yarn lint:watch

Other gulp tasks:

# Wipe out dist and coverage directory
gulp clean

# Default task: Wipes out dist and coverage directory. Compiles using babel.
gulp

Deployment

# compile to ES5
1. npm run build

# upload dist/ to your server
2. scp -rp dist/ user@dest:/path

# Use any process manager to start your services
4. pm2 start dist/index.js

Logging

Universal logging library winston is used for logging. It has support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file. We just log to the console for simplicity, you can configure more transports as per your requirement.

API logging

Logs detailed info about each api request to console during development. Detailed API logging

Error logging

Logs stacktrace of error to console along with other details. You should ideally store all error messages persistently. Error logging

Code Coverage

Get code coverage summary on executing yarn test:coverage Code Coverage Text Summary

yarn test:coverage also generates HTML code coverage report in coverage/ directory. Open lcov-report/index.html to view it. Code coverage HTML report

Docker Deployment

Docker Compose:

# In `.env` file, assign `UNIQUE_NAME_PG_HOST` to amida-db
1. sed -i s/localhost/amida-db/ .env

# Run:
2. yarn build && docker-compose up

AWS Deployment

The basic steps for deploying to AWS are:

  1. Run the Packer script, template.json
  2. Run the Terraform script.

Further details can be found in the deploy directory.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published