Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Latest commit

 

History

History
175 lines (120 loc) · 4.45 KB

README.md

File metadata and controls

175 lines (120 loc) · 4.45 KB

Adoption Frontend

Greenkeeper badge

Standard - JavaScript Style Guide

codecov

Purpose

This is the frontend application for Adoption. Service provides web UI for citizens, presented as sequence of HTML 5 web pages designed to GDS Service Design guidelines, so that they can make adoption application.

Getting Started

Prerequisites

Running the application requires the following tools to be installed in your environment:

Running the application

Install dependencies by executing the following command:

$ yarn install

Run:

$ yarn run build:dev

The applications's home page will be available at https://localhost:3000

Running with Docker

Create docker image:

  docker-compose build

Run the application by executing the following command:

  docker-compose up

This will start the frontend container exposing the application's port

In order to test if the application is up, you can visit https://localhost:3000 in your browser.

Developing

Code style

We use TSLint alongside sass-lint

Running the linting:

$ yarn lint

Running the linting with auto fix:

$ yarn lint --fix

Running the tests

This template app uses Mocha as the test engine. You can run unit tests by executing the following command:

$ yarn test

Here's how to run functional tests (the template contains just one sample test):

$ yarn test:routes

Running accessibility tests:

$ yarn test:a11y

Make sure all the paths in your application are covered by accessibility tests (see a11y.ts).

Debugging the application

Node inspector is enabled, Whilst running the application in development mode using yarn build:dev.

See below how to attach a debugger in the IDE.

Debug in Visual Studio Code

To set up the debug configuration in vscode, create the following file in project root folder:-

.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Node: Nodemon",
      "port": 9229,
      "restart": true,
      "protocol": "inspector",
      "address": "localhost"
    }
  ]
}

Security

CSRF prevention

Cross-Site Request Forgery prevention has already been set up in this template, at the application level. However, you need to make sure that CSRF token is present in every HTML form that requires it. For that purpose you can use the csrfProtection macro, included in this template app. Your njk file would look like this:

{% from "macros/csrf.njk" import csrfProtection %}
...
<form ...>
  ...
    {{ csrfProtection(csrfToken) }}
  ...
</form>
...

Helmet

This application uses Helmet, which adds various security-related HTTP headers to the responses. Apart from default Helmet functions, following headers are set:

There is a configuration section related with those headers, where you can specify:

  • referrerPolicy - value of the Referrer-Policy header

Here's an example setup:

    "security": {
      "referrerPolicy": "origin"
    }

Make sure you have those values set correctly for your application.

Healthcheck

The application exposes a health endpoint (https://localhost:3000/health), created with the use of Nodejs Healthcheck library. This endpoint is defined in health.ts file. Make sure you adjust it correctly in your application. In particular, remember to replace the sample check with checks specific to your frontend app, e.g. the ones verifying the state of each service it depends on.

License

This project is licensed under the MIT License - see the LICENSE file for details