- Install the dependencies required to run the service:
$ yarn
-
Supply environment variables. The required environment variables are defined in server/config.js.
-
Start the server
$ yarn run start
Or, for development, run inspections, tests, watch for changes and start the server:
$ yarn run dev
- Visit localhost:3000
yarn run lint-> style checks using eslintyarn run test-> runs all unit testsyarn run clean-> cleans previously generated filesyarn run build-> cleans and regenerates assets.
The following environment variables are used and values should be supplied for correct operation but have defaults.
- NOMIS_API_URL - url for nomis elite2 api entry point eg http://localhost:9090/elite2api
- NOMIS_GW_TOKEN - MoJ dev token for nomis elite2 access
- NOMIS_GW_KEY - Base64 encoded private key corresponding to the public key used when generating the NOMIS_GW_TOKEN
For the database:
- DB_USER - username for DB access
- DB_PASS - password for DB access
- DB_SERVER - DB server host
- DB_NAME - DB name
- DB_SSL_ENABLED - set to false for local
For the PDF generator service
- PDF_TEMPLATE_NAME - Name of template to use eg 'hdc_ap_pss'
- PDF_SERVICE_HOST - Root of PDF generator service eg 'http://localhost:8081' or 'http://localhost:9090' if using wiremock
When accessing the AWS Postgres databases eg for the stage env, SSL must be enabled (DB_SSL_ENABLED=true) and you need a file in the root of the project called root.cert containing the AWS RDS root certificate
see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html
Migrations are managed using knex and knex-migrate
Execute migration
yarn migrate
Other migration commands
yarn run knex-migrate <command>
Commands
- pending Lists all pending migrations
- list Lists all executed migrations
- up Performs all pending migrations
- down Rollbacks last migration
- rollback Rollbacks last batch of migrations
- redo Rollbacks last batch and performs all migrations
Create a new migration script
yarn run knex migrate:make <script-name>
Execute seed scripts to populate DB with test data
yarn seed
Create a new seed file
yarn run knex seed:make <script-name>
CREATE DATABASE licences CONTAINMENT = PARTIAL