Skip to content

FoodStandardsAgency/register-a-food-business-service

Repository files navigation

Register a food business service

Setting up your development environment

To run this application, you must use the register-a-food-business-environment repository to set up your development environment.

It is recommended that you install the Prettier code-formatting extension for your IDE.

Detailed guides

The following detailed guides are available:

The /api/registration route

The /api/registration route is the endpoint for creating, fetching, and deleting registrations.

POST /api/registration/createNewRegistration

A successful POST request to the /createNewRegistration route requires the following:

  • A POST body in application/json format, containing the registration data, in the data structure defined in validation.schema.js
  • Four POST headers:
    • Content-Type: application/json
    • client-name: currently there is only one permitted client, the front-end application, and its name is stored in the environment variables for this service application.
    • api-secret: the corresponding secret for client-name.
    • registration-data-version: a string version number, in Semver format, to correlate with one of the entries in the configVersion collection in the Config database.

A successful POST request to the /createNewRegistration route performs the following actions, in order:

  • Saves the registration data to the *-back-end-cache database on Azure. This action means that any failed subsequent steps will be recoverable via a manual search of the cache database, rather than the user data being lost forever.
  • Validates the registration data against the schema
  • Fetches the config details (such as contact details) for the specified district council and, optionally, its corresponding county council in cases where the county council manages food standards.
  • Gets metadata for the registration. Currently, this is the unique food business registration application reference (via an Epimorphics API) and the registration date in YYYY-MM-DD format.
  • Sends a combined response object back to the client
  • Performs a series of asynchronous post-response operations:
    • Sends the registration to the Tascomi API specified in the config database for that council
    • Saves the registration to the PostgreSQL database (*-temp-store) on Azure
    • Gets the config for the specified registration-data-version, which includes template IDs for GOV.UK Notify emails
    • Sends confirmation/notification emails to the Food Business Operator and Local Council(s) via GOV.UK Notify.

DELETE /api/registration/:fsa_rn

This route is primarily in place to allow easy actioning of GDPR deletion requests on individual registrations by the FSA registration application reference, or other required registration deletions. The client-name and api-secret headers are required to use this route. Note that the matching environment variables are the ADMIN_* variables, which are different to those for the POST/createNewRegistration route.

GET /api/registration/:fsa_rn

This route is deprecated because the collections service now provides all GET functionality for saved registrations. However, the route can be used for admin purposes if necessary. The client-name and api-secret headers are required to use this route. Note that the matching environment variables are the ADMIN_* variables, which are different to those for the POST/createNewRegistration route.