Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

A Restful service to provide access to the VIPER Rating for a known ID

License

Notifications You must be signed in to change notification settings

ministryofjustice/viper-service

Repository files navigation

VIPER Rating Service

A Restful service to provide access to the VIPER Rating for a known ID

CircleCI

Swagger documentation

The details of the API can found in the online documentation.

The swagger specification can be found on the path /api-docs.

Running with NodeJS

Start by ensuring you have the most recent version of NodeJS and NPM installed.

Pre-requisites

To find the current version of NodeJS installed on your system, run the following command in your preferred shell;

$ node -v

If you have the latest versions installed you need to get the dependencies loaded, run the following command in your preferred shell;

$ npm install

Running the tests

If you have all the Pre-requisites then you are ready to run the tests. Call the following from your shell;

$ npm test

Running the server

If you have all the Pre-requisites then you are ready to run the service. Call the following from your shell;

$ npm start

Running the server with raw logs

If you wish to have the output in raw JSON, then you can run the server without piping it through bunyan's formatter. Call the following from your shell;

$ node server.js

Running the CicleCI build locally

This can be done using the circleci CLI command, you'll need to set the SNYK_TOKEN environment variable to make this work.

Database connections

This can be left out in dev mode, and any API routes which use the database will fail.

In production the DB connection config is required. The variable should be set like this:

DB_URI=mssql://username:password@server-host:1433/database-name

Migrations

Migrations are managed using knex.

You can execute them with

npm run migrate

Other knex commands can be run via

npm run knex -- <other args>

Seed data

To reset the database back into a known-data state, you can use the seed scripts

npm run seed

Local database setup

To run the database locally, use the docker image.

docker pull microsoft/mssql-server-linux
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<password>' -p 1433:1433 -d microsoft/mssql-server-linux

After you have a database, you'll need to create the database and application user. On real environments this is handled by the terraform code.

export DB_URI=mssql://sa:<password>@localhost:1433/<database-name>
DB_USER=<database-user> DB_PASSWORD=<database-user-password> npm run setup-mssql

And then run the migrations & seeds as with any other environment.

npm run knex -- migrate:currentVersion
npm run migrate
npm run seed

Local database manual querying

The sql-cli package on npm gives you a commandline client called mssql.

npm install -g sql-cli
mssql -s localhost -u <database-user> -p <database-user-password> -d <database-name>

Performing a data upload

TBC

About

A Restful service to provide access to the VIPER Rating for a known ID

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published