Skip to content

UKHomeOffice/egar-public-site-ui

Repository files navigation

Submit a GAR (sGAR)

Prerequisites

  • Clone the data-access-apirepo in the same parent folder and set up environment variables as explained in the data-access-api README.md.

Requirements

  • docker and docker compose.
  • create a .env.dev file and input environment variables - ask a developer in the SGAR team for them.

Run the application

  1. Run the following:
docker compose up -d --build

This should build both the data-access-api and egar-public-site-ui.

  • The frontend will now be running on port 3000.
  • To see changes on the frontend, reload the page.

Generate airport codes data (airport_codes.json)

The airport codes used by the app are generated from a CSV file.

  • To add or update an airport code: edit src/common/app_data/airport_codes.csv.
  • Then run the Node script below to regenerate src/common/app_data/airport_codes.json.
# From the project root
node scripts/generate_airport_codes.js

Notes:

  • Do not manually edit src/common/app_data/airport_codes.json; it is derived from the CSV.
  • The generator enforces sorting and normalisation and will overwrite the JSON file.
  • The resulting JSON includes an additional value field (priority: IATA > ICAO > first otherCode).

Unit tests

Run the below to access the node container, which will have all the installed dependencies, so you can run the npm test script.

docker exec  -it node sh

# Now run the test script
npm run test

Access the database

Run the following to access the database so you can run SQL commands.

docker exec -it database sh

# Log into postgres with the following command
psql -U user -d egar
# RUN you sql commands after wards

Mock clamav

  • To use the mock clamav container, you need to specific the following environment variables in the .env.dev:
CLAMAV_BASE=http://mock-clamav
CLAMAV_PORT=8080

Other repositories

In general you don't need to run gateway-api and data-integr-cbp, unless:

  • You want to mock submitting a GAR to CBP.
  • If you are mocking a flight from a foreign country to the UK and need check their UPT status.

Structure of app

  • Files are organised to match route path, e.g. ./app/garfile/manifest --> http://localhost:3000/garfile/manifest.
    • Occasionally, the route path may deviate from this rule e.g. upload gar spreadsheet is under ./api/uploadgar rather than ./garfile/garupload.
  • GET and POST request handlers are separated out in get.controller.js and post.controller.js.
  • ./test file structure roughly maps the ./app file structure e.g. test/garfile/garupload/get.controller.test.jsis the test for./app/garfile/garupload/get.controller.js`.
  • public folders contains frontend scripts, stylesheets and html that is sent to the user.
  • locales contains text used in the app.
  • common contains common functionalty used in app.