Skip to content

catapultcx/animals-ui

Repository files navigation

GOV.UK express

This is a working NodeJS (express) web application that uses the GOV.UK frontend and adheres to the GOV.UK Design System.

It also acts as the standard for how an express project should be structured, and what files are expected.

It can be copied and used at the starting point for any new web app.

Project structure

NodeJS services in the MCA follow the express routes/controllers pattern, along with with service classes that CRUD data.

src
+-- bin
|   -- www.js
|   controllers    
|   routes    
|   views
|   services
|   ...    
test
--- web
--- services
--- ...
Expected project files

Each project should have the following files:

Name Purpose
README.md Explanation of the module and how to use it
package.json For building with npm
Dockerfile To build a Docker image
docker-compose.yml To run the Docker image and all dependencies
www.js To start the service
.gitignore Files to be ignored from SCM

Prerequisites and setup

Developers should install the following on their machines:

Optional

Environment variables are defined in the .env.example file. This should be copied locally into .env but NOT commited.

View templating

This project uses nunjucks for its view templating.

Commands

Development

Install the dependencies

npm install nyc -g
npm install

Test (first start animals-api service)

npm test

Run locally

npm start
Docker

Note: these are not tested on all environments, if you struggle with them then just start the service with npm start

If you are familiar with docker you may wish to use it to run the service.

Run locally

docker-compose up

Run UI from Docker Hub

docker run --rm -p 2997:2997 -d --env API_URL=http://<YOUR_NETWORK_IP>:8080/api/1 catapultcx/animals-ui:latest

Run API from Docker Hub

docker run --rm -p 8080:8080 -d catapultcx/animals-api:latest

Publish to Docker Hub

./docker.sh

Accessing locally

The service will be available at http://localhost:2997/

Releases

No releases published

Packages

No packages published