forked from DepartmentOfHealth-htbhf/htbhf-applicant-web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Defining a journey
Matt Smith edited this page Jan 24, 2020
·
2 revisions
Flow based user journeys are defined in the journey definitions file. To register a journey, add a journey object to the exported array.
Journeys are defined as javascript objects that implement the following schema:
| Property | Type | Description |
|---|---|---|
name |
string | The name of the journey. A unique identifier that is used internally by the application |
endpoint |
string | The endpoint on the claimant service that is used when a POST request is made at the end of the journey. Must start with /
|
pathPrefix optional
|
string | A unique URL segment to prefix step paths when the journey routes are registered. Must start with /
|
steps |
step[] | an ordered array of step objects. The order of the array determines the order of the steps in the journey |
An example journey definition:
// journey-definitions.js
...
const MY_JOURNEY = {
name: 'my-journey',
pathPrefix: '/my-journey',
endpoint: '/v2/claims',
steps: [name, nationalInsuranceNumber, emailAddress]
}
module.exports.JOURNEYS = [..., MY_JOURNEY]
At the end of each journey a POST request is made to the claimant service. The body of the request is defined by the journey steps. The journey endpoint property defines the endpoint on the claimant service that the request is sent to.
A unique URL segment to prefix step paths when the journey routes are registered. Must start with /. This allows each journey to have a unique URL and enables reuse of steps across multiple journeys:
// steps/my-step.js
const myStep = {
...
path: '/my-path'
}
// journey-definitions.js
const myJourney = {
...
pathPrefix: '/my-journey',
steps: [myStep]
}
const myOtherJourney = {
...
pathPrefix: '/my-other-journey',
steps: [myStep]
}
// This will result in two routes being registered with the paths:
// - /my-journey/my-path
// - /my-other-journey/my-path