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.
NodeJS services in the MCA follow the express routes/controllers pattern, along with with service classes that CRUD data.
src
+-- bin
| -- www
| controllers
| routes
| views
| services
| ...
test
--- web
--- services
--- ...
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 | To start the service |
.gitignore | Files to be ignored from SCM |
Developers should install the following on their machines:
Environment variables are defined in the .env.example
file. This should be copied locally into
.env
but NOT commited.
This project uses nunjucks for its view templating.
Install the dependencies
npm install grunt -g
npm install nyc -g
npm install
Test (first start animals-api
service)
npm test
Run locally
npm start
Run locally
docker-compose up
The service will be available at http://localhost:2997/