A Restful service to provide access to the VIPER Rating for a known ID
The details of the API can found in the online documentation.
The swagger specification can be found on the path /api-docs
.
Start by ensuring you have the most recent version of NodeJS and NPM installed.
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
If you have all the Pre-requisites then you are ready to run the tests. Call the following from your shell;
$ npm test
If you have all the Pre-requisites then you are ready to run the service. Call the following from your shell;
$ npm start
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
This can be done using the circleci
CLI command, you'll need to set the SNYK_TOKEN
environment variable to make this work.
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 are managed using knex.
You can execute them with
npm run migrate
Other knex commands can be run via
npm run knex -- <other args>
To reset the database back into a known-data state, you can use the seed scripts
npm run seed
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
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>
TBC