6.6.1-cmg • Published 3 years ago

govuk-casa v6.6.1-cmg

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

CASA

Build Status

A compact framework for building government services based on the GOV.UK Design System.

Support

CASA is maintained by the DWP Engineering Practice.

Contributing

If you'd like to contribute any changes, enhancements or report issues, please take a look at our contribution guide.

Features

  • Adopts the GOVUK Design System which provides well-researched, accessible markup out of the box
  • Handles complex, conditional journey routing logic so you easily tailor users' journeys on the fly
  • Provides basic protection against some OWASP Top Ten vulnerabilities such as XSS, CSRF
  • Choose your own session management extension for customised data storage (e.g. apply encryption as required)
  • Shallow learning curve

Getting started

CASA aims to maintain support for the latest CURRENT even version and the previous LTS version of NodeJS (currently 13 and 12 respectively as of Feb 2020), and requires at least version 6.4.0 of npm. See the NodeJS release schedule for more information.

Prepare your new project and install dependencies:

mkdir -p my-project
cd my-project
npm init -y
npm install --save-exact express express-session @dwp/govuk-casa

You can use any folder structure you're most comfortable with, but here's a suggested convention:

definitions/
  field-validators/
  plan.js
  pages.js
locales/
  en/
  cy/
routes/
static/
views/
  layouts/
  pages/
  partials/
app.js

If you just want to get a quick and dirty CASA application up and running, take a look at Deploying a CASA app first or browse through one of the example applications.

However, if you'd like to build an understanding of the core concepts involved in building a CASA app, a good place to start is to begin designing your Routes Plan. This will provide CASA with information about the high-level flows that a user takes through your service, including the various conditional forks that may appear in the journey. Visit Designing a Route Plan to get started.

Once your plan begins to take shape, you can start to create the HTML pages that will take your users through the various routes within it, capturing data from them along the way. All markup is generated through Nunjucks templates, and you can use the GOVUK Design System components to generate elements that match the GOVUK styling. Visit Creating Pages to get started.

Now you've got some pages ready to collect data from the user, you'll most likely want to add a bit of validation logic to those data fields to make sure you're capturing the right stuff, in the right format. Visit Defining Field Validation to get started.

Finally, we need to bring all of this together, by creating a bootstrap script for our service. Visit Deploying a CASA app to get started.

That's it! The basics have been covered here, but if you want to delve deeper under the hood then take a read through the developer API documentation too.

Testing your app

CASA provides a basic testTraversal() utility function that can help to test that the routes defined in your Plan are executed in the expected sequence when given a series of defined data inputs.