Skip to content

ministryofjustice/hmpps-find-and-refer-an-intervention-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hmpps-find-and-refer-an-intervention-ui

repo standards badge CircleCI

This repository contains the ui code for the Find and Refer an Intervention UI.

Required software

Most software can be installed using homebrew.

  • Docker
  • Node (v20)

Running the application locally

After setting up the dependencies (below), run the application locally with with:

npm run start:dev

The dev server comes with Hot Module Reloading (reloads and restarts when any file changes are detected)

Docker

This project includes docker compose files to start the required dependencies for running the UI locally.

Run the following command to pull the relevant dependencies for the project.

docker-compose pull

and then the following command to run the containers.

docker-compose up

can optionally be run in detached mode in order to retain terminal use

docker-compose up -d

Environment Files (.env)

Node requires a .env file to start the application, but the project does not make heavy use of environmental variables.

Before starting the application create a new blank .env file by either creating a blank .env file:

touch .env

or copying the example file:

cp .env.example .env

Connecting to local database

The service uses a postgres database alongside flyaway migrations to create and populate the database. To connect to the database locally in your preferred database client (IntelliJ Ultimate, Dbeaver, Pgadmin, etc).

Create new connection using local database credentials;

Variable Value
Port 5432
Username postgres
Password password

Authorization

The service uses an Oauth 2.0 setup managed through the Hmpps Auth project. To call any endpoints locally a bearer token must be generated. This can be done through calling the auth endpoint in the Hmpps-auth service.

Variable Value
Grant type Client credentials
Access token URL http://hmpps-auth:8090/auth/oauth/token
Client ID -----
Client Secret -----
Scope Read

For Client ID and Secret refer to the relevant credentials for the Find and Refer Project.

Troubleshooting

For any issues please reach out to the Find and Refer Interventions team in slack #find-refer-interventions-team

Client Credentials flow

These are used by the application to request tokens to make calls to APIs. These are system accounts that will have their own sets of roles.

Most API calls that occur as part of the request/response cycle will be on behalf of a user. To make a call on behalf of a user, a username should be passed when requesting a system token. The username will then become part of the JWT and can be used downstream for auditing purposes.

These tokens are cached until expiration.

These credentials are configured using the following env variables:

  • CLIENT_CREDS_CLIENT_ID
  • CLIENT_CREDS_CLIENT_SECRET

System tokens are obtained by making a call to HMPPS-Auth using the username of the logged in user. This token can then be added to the appropriate rest client calling to another service.

Logging in with a test user

Once the application is running you should then be able to login with:

Community User username: bernard.beaks password: secret

Custody User username: FR_USER password: password123456

Extra commands

Run linter

  • npm run lint runs eslint.
  • npm run typecheck runs the TypeScript compiler tsc.

Run unit tests

npm run test

Change log

A changelog for the service is available here

About

UI for Find and Refer an Intervention Service

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published