@dwp/govuk-casa 8.0.2 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +2 -0
  3. package/dist/assets/css/casa-ie8.css +1 -1
  4. package/dist/assets/css/casa.css +1 -1
  5. package/dist/casa.d.ts +210 -0
  6. package/dist/casa.js +107 -1
  7. package/dist/lib/CasaTemplateLoader.d.ts +7 -0
  8. package/dist/lib/JourneyContext.d.ts +15 -27
  9. package/dist/lib/JourneyContext.js +37 -16
  10. package/dist/lib/configuration-ingestor.d.ts +21 -139
  11. package/dist/lib/configuration-ingestor.js +39 -84
  12. package/dist/lib/configure.d.ts +6 -77
  13. package/dist/lib/configure.js +82 -40
  14. package/dist/lib/index.js +5 -1
  15. package/dist/lib/nunjucks.d.ts +1 -6
  16. package/dist/lib/nunjucks.js +1 -3
  17. package/dist/lib/utils.d.ts +21 -10
  18. package/dist/lib/utils.js +54 -8
  19. package/dist/lib/validators/dateObject.d.ts +1 -0
  20. package/dist/lib/validators/email.d.ts +2 -0
  21. package/dist/lib/validators/inArray.d.ts +2 -0
  22. package/dist/lib/validators/nino.d.ts +2 -0
  23. package/dist/lib/validators/postalAddressObject.d.ts +1 -0
  24. package/dist/lib/validators/regex.d.ts +2 -0
  25. package/dist/lib/validators/required.d.ts +4 -0
  26. package/dist/lib/validators/strlen.d.ts +2 -0
  27. package/dist/lib/validators/wordCount.d.ts +2 -0
  28. package/dist/lib/waypoint-url.js +8 -2
  29. package/dist/middleware/body-parser.js +1 -1
  30. package/dist/middleware/data.d.ts +1 -2
  31. package/dist/middleware/data.js +12 -2
  32. package/dist/middleware/post.d.ts +1 -3
  33. package/dist/middleware/post.js +3 -3
  34. package/dist/middleware/pre.d.ts +4 -2
  35. package/dist/middleware/pre.js +24 -5
  36. package/dist/middleware/progress-journey.d.ts +1 -2
  37. package/dist/middleware/progress-journey.js +2 -2
  38. package/dist/middleware/session.d.ts +1 -2
  39. package/dist/middleware/session.js +12 -6
  40. package/dist/middleware/skip-waypoint.d.ts +1 -2
  41. package/dist/middleware/skip-waypoint.js +2 -2
  42. package/dist/middleware/steer-journey.d.ts +1 -2
  43. package/dist/middleware/steer-journey.js +2 -2
  44. package/dist/middleware/validate-fields.d.ts +1 -2
  45. package/dist/middleware/validate-fields.js +2 -1
  46. package/dist/routes/journey.d.ts +1 -2
  47. package/dist/routes/journey.js +8 -8
  48. package/dist/routes/static.d.ts +1 -6
  49. package/dist/routes/static.js +6 -6
  50. package/package.json +32 -30
  51. package/views/casa/components/journey-form/README.md +3 -0
  52. package/views/casa/components/journey-form/template.njk +1 -1
  53. package/views/casa/partials/scripts.njk +1 -1
  54. package/views/casa/partials/styles.njk +2 -2
@@ -6,7 +6,7 @@
6
6
  * @throws {TypeError} For invalid object.
7
7
  * @returns {object} Sanitised i18n object.
8
8
  */
9
- export function validateI18nObject(i18n: object, cb?: Function): object;
9
+ export function validateI18nObject(i18n?: object, cb?: Function): object;
10
10
  /**
11
11
  * Validates and sanitises i18n directory.
12
12
  *
@@ -15,7 +15,7 @@ export function validateI18nObject(i18n: object, cb?: Function): object;
15
15
  * @throws {TypeError} For invalid type.
16
16
  * @returns {Array} Array of directories.
17
17
  */
18
- export function validateI18nDirs(dirs: any[]): any[];
18
+ export function validateI18nDirs(dirs?: any[]): any[];
19
19
  /**
20
20
  * Validates and sanitises i18n locales.
21
21
  *
@@ -24,7 +24,7 @@ export function validateI18nDirs(dirs: any[]): any[];
24
24
  * @throws {TypeError} For invalid type.
25
25
  * @returns {Array} Array of locales.
26
26
  */
27
- export function validateI18nLocales(locales: any[]): any[];
27
+ export function validateI18nLocales(locales?: any[]): any[];
28
28
  /**
29
29
  * Validates and sanitises mount url.
30
30
  *
@@ -42,7 +42,7 @@ export function validateMountUrl(mountUrl: string, name?: string): string;
42
42
  * @throws {TypeError} For invalid object.
43
43
  * @returns {object} Sanitised sessions object.
44
44
  */
45
- export function validateSessionObject(session: object, cb?: Function): object;
45
+ export function validateSessionObject(session?: object, cb?: Function): object;
46
46
  /**
47
47
  * Validates and sanitises view directory.
48
48
  *
@@ -51,7 +51,7 @@ export function validateSessionObject(session: object, cb?: Function): object;
51
51
  * @throws {TypeError} For invalid type.
52
52
  * @returns {Array} Array of directories.
53
53
  */
54
- export function validateViews(dirs: any[]): any[];
54
+ export function validateViews(dirs?: any[]): any[];
55
55
  /**
56
56
  * Validates and sanitises sessions secret.
57
57
  *
@@ -69,25 +69,25 @@ export function validateSessionSecret(secret: string): string;
69
69
  * @throws {TypeError} For invalid value.
70
70
  * @returns {number} Ttl.
71
71
  */
72
- export function validateSessionTtl(ttl: number): number;
72
+ export function validateSessionTtl(ttl?: number): number;
73
73
  /**
74
74
  * Validates and sanitises sessions name.
75
75
  *
76
- * @param {string} name Session name.
76
+ * @param {string} [name=casa-session] Session name.
77
77
  * @throws {ReferenceError} For missing value type.
78
78
  * @throws {TypeError} For invalid value.
79
79
  * @returns {string} Name.
80
80
  */
81
- export function validateSessionName(name: string): string;
81
+ export function validateSessionName(name?: string | undefined): string;
82
82
  /**
83
83
  * Validates and sanitises sessions secure flag.
84
84
  *
85
- * @param {boolean} secure Session secure flag.
85
+ * @param {boolean} [secure=false] Session secure flag.
86
86
  * @throws {ReferenceError} For missing value type.
87
87
  * @throws {TypeError} For invalid value.
88
88
  * @returns {string} Name.
89
89
  */
90
- export function validateSessionSecure(secure: boolean): string;
90
+ export function validateSessionSecure(secure?: boolean | undefined): string;
91
91
  /**
92
92
  * Validates and sanitises sessions store.
93
93
  *
@@ -119,11 +119,19 @@ export function validateSessionCookiePath(cookiePath: string, defaultPath?: stri
119
119
  export function validateSessionCookieSameSite(cookieSameSite: any, defaultFlag: any): boolean;
120
120
  export function validatePageHooks(hooks: any): any[];
121
121
  export function validateFields(fields: any): any[];
122
- export function validatePages(pages: any): any[];
122
+ export function validatePages(pages?: any[]): any[];
123
123
  export function validatePlan(plan: any): any;
124
124
  export function validateGlobalHooks(hooks: any): any[];
125
125
  export function validatePlugins(plugins: any): any;
126
126
  export function validateEvents(events: any): any;
127
+ /**
128
+ * Validates helmet configuration function.
129
+ *
130
+ * @param {HelmetConfigurator} helmetConfigurator Configuration function
131
+ * @returns {HelmetConfigurator} Validated configuration function
132
+ * @throws {TypeError} when passed a non-function
133
+ */
134
+ export function validateHelmetConfigurator(helmetConfigurator: HelmetConfigurator): HelmetConfigurator;
127
135
  /**
128
136
  * Ingest, validate, sanitise and manipulate configuration parameters.
129
137
  *
@@ -132,131 +140,5 @@ export function validateEvents(events: any): any;
132
140
  * @returns {object} Immutable config object.
133
141
  */
134
142
  export default function ingest(config?: ConfigurationOptions): object;
135
- export type ContextEvent = import('./index').ContextEvent;
136
- export type SessionOptions = {
137
- /**
138
- * Session name
139
- */
140
- name?: string | undefined;
141
- /**
142
- * Encryption secret
143
- */
144
- secret?: string | undefined;
145
- /**
146
- * Session ttl (seconds)
147
- */
148
- ttl?: number | undefined;
149
- /**
150
- * Whether to use secure session cookies
151
- */
152
- secure?: boolean | undefined;
153
- /**
154
- * SameSite (true = Strict)
155
- */
156
- cookieSameSite?: string | boolean | undefined;
157
- /**
158
- * Session store (default MemoryStore)
159
- */
160
- store?: object | undefined;
161
- };
162
- export type I18nOptions = {
163
- /**
164
- * Directories to search for locale dictionaries
165
- */
166
- dirs: string[];
167
- /**
168
- * Supported locales
169
- */
170
- locales?: string[] | undefined;
171
- };
172
- /**
173
- * Hook configuration
174
- */
175
- export type GlobalHook = {
176
- /**
177
- * Hook name in format `<router>.<hook>`
178
- */
179
- hook: string;
180
- /**
181
- * Middleware function to insert at the hook point
182
- */
183
- middleware: Function;
184
- /**
185
- * Only run if route path matches this string/regexp
186
- */
187
- path?: string | RegExp | undefined;
188
- };
189
- /**
190
- * (extends GlobalHook)
191
- */
192
- export type PageHook = {
193
- /**
194
- * Hook name (without a scope prefix)
195
- */
196
- hook: string;
197
- /**
198
- * Middleware function to insert at the hook point
199
- */
200
- middleware: Function;
201
- };
202
- /**
203
- * Page configuration. A Page is the interactive representation of a waypoint
204
- */
205
- export type Page = {
206
- /**
207
- * The waypoint with which this page is associated
208
- */
209
- waypoint: string;
210
- /**
211
- * Template path
212
- */
213
- view: string;
214
- /**
215
- * Page-specific hooks (optional, default [])
216
- */
217
- hooks?: PageHook[] | undefined;
218
- /**
219
- * Fields to be managed on this page (optional, default [])
220
- */
221
- fields?: PageField[] | undefined;
222
- };
223
- /**
224
- * Configuration options
225
- */
226
- export type ConfigurationOptions = {
227
- mountUrl?: string | undefined;
228
- /**
229
- * Template directories
230
- */
231
- views?: string[] | undefined;
232
- /**
233
- * Session configuration
234
- */
235
- session?: SessionOptions | undefined;
236
- /**
237
- * Pages the represent waypoints
238
- */
239
- pages?: Page[] | undefined;
240
- /**
241
- * Hooks to apply
242
- */
243
- hooks?: GlobalHook[] | undefined;
244
- /**
245
- * Plugins
246
- */
247
- plugins?: object[] | undefined;
248
- /**
249
- * I18n configuration
250
- */
251
- i18n?: I18nOptions[] | undefined;
252
- /**
253
- * CASA Plan
254
- */
255
- plan: Plan;
256
- /**
257
- * Handlers for JourneyContext events
258
- */
259
- events?: any[] | undefined;
260
- };
261
- import { PageField } from "./field.js";
262
- import Plan from "./Plan.js";
143
+ export type ConfigurationOptions = import('../casa').ConfigurationOptions;
144
+ export type HelmetConfigurator = import('../casa').HelmetConfigurator;
@@ -3,63 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateEvents = exports.validatePlugins = exports.validateGlobalHooks = exports.validatePlan = exports.validatePages = exports.validateFields = exports.validatePageHooks = exports.validateSessionCookieSameSite = exports.validateSessionCookiePath = exports.validateSessionStore = exports.validateSessionSecure = exports.validateSessionName = exports.validateSessionTtl = exports.validateSessionSecret = exports.validateViews = exports.validateSessionObject = exports.validateMountUrl = exports.validateI18nLocales = exports.validateI18nDirs = exports.validateI18nObject = void 0;
6
+ exports.validateHelmetConfigurator = exports.validateEvents = exports.validatePlugins = exports.validateGlobalHooks = exports.validatePlan = exports.validatePages = exports.validateFields = exports.validatePageHooks = exports.validateSessionCookieSameSite = exports.validateSessionCookiePath = exports.validateSessionStore = exports.validateSessionSecure = exports.validateSessionName = exports.validateSessionTtl = exports.validateSessionSecret = exports.validateViews = exports.validateSessionObject = exports.validateMountUrl = exports.validateI18nLocales = exports.validateI18nDirs = exports.validateI18nObject = void 0;
7
7
  /* eslint-disable sonarjs/no-duplicate-string */
8
8
  const field_js_1 = require("./field.js");
9
9
  const Plan_js_1 = __importDefault(require("./Plan.js"));
10
10
  const logger_js_1 = __importDefault(require("./logger.js"));
11
11
  const utils_js_1 = require("./utils.js");
12
12
  /**
13
- * @typedef {import('./index').ContextEvent} ContextEvent
13
+ * @typedef {import('../casa').ConfigurationOptions} ConfigurationOptions
14
14
  */
15
15
  /**
16
- * @typedef {object} SessionOptions
17
- * @property {string} [name=casasession] Session name
18
- * @property {string} [secret=secret] Encryption secret
19
- * @property {number} [ttl=3600] Session ttl (seconds)
20
- * @property {boolean} [secure=false] Whether to use secure session cookies
21
- * @property {boolean|string} [cookieSameSite=true] SameSite (true = Strict)
22
- * @property {object} [store] Session store (default MemoryStore)
23
- */
24
- /**
25
- * @typedef {object} I18nOptions
26
- * @property {string[]} dirs Directories to search for locale dictionaries
27
- * @property {string[]} [locales=['en', 'cy']] Supported locales
28
- */
29
- /**
30
- * @typedef {object} GlobalHook Hook configuration
31
- * @property {string} hook Hook name in format `<router>.<hook>`
32
- * @property {Function} middleware Middleware function to insert at the hook point
33
- * @property {string|RegExp} [path=undefined] Only run if route path matches this string/regexp
34
- */
35
- /**
36
- * @typedef {object} PageHook (extends GlobalHook)
37
- * @property {string} hook Hook name (without a scope prefix)
38
- * @property {Function} middleware Middleware function to insert at the hook point
39
- */
40
- /**
41
- * @typedef {object} Page Page configuration. A Page is the interactive representation of a waypoint
42
- * @property {string} waypoint The waypoint with which this page is associated
43
- * @property {string} view Template path
44
- * @property {PageHook[]} [hooks=[]] Page-specific hooks (optional, default [])
45
- * @property {PageField[]} [fields=[]] Fields to be managed on this page (optional, default [])
46
- */
47
- /**
48
- * Configure some middleware for use in creating a new CASA app.
49
- *
50
- * `mountUrl` is used to ensure the CSS content uses the correct reference to
51
- * static assets in the `govuk-frontend` module.
52
- *
53
- * @typedef {object} ConfigurationOptions Configuration options
54
- * @property {string} [mountUrl=/] URL path to root of CASA app
55
- * @property {string[]} [views=[]] Template directories
56
- * @property {SessionOptions} [session] Session configuration
57
- * @property {Page[]} [pages=[]] Pages the represent waypoints
58
- * @property {GlobalHook[]} [hooks=[]] Hooks to apply
59
- * @property {object[]} [plugins=[]] Plugins
60
- * @property {I18nOptions[]} [i18n] I18n configuration
61
- * @property {Plan} plan CASA Plan
62
- * @property {ContextEvent[]} [events=[]] Handlers for JourneyContext events
16
+ * @typedef {import('../casa').HelmetConfigurator} HelmetConfigurator
63
17
  */
64
18
  const log = (0, logger_js_1.default)('lib:configuration-ingestor');
65
19
  const echo = (a) => (a);
@@ -71,7 +25,7 @@ const echo = (a) => (a);
71
25
  * @throws {TypeError} For invalid object.
72
26
  * @returns {object} Sanitised i18n object.
73
27
  */
74
- function validateI18nObject(i18n, cb = echo) {
28
+ function validateI18nObject(i18n = Object.create(null), cb = echo) {
75
29
  if (Object.prototype.toString.call(i18n) !== '[object Object]') {
76
30
  throw new TypeError('I18n must be an object');
77
31
  }
@@ -86,11 +40,8 @@ exports.validateI18nObject = validateI18nObject;
86
40
  * @throws {TypeError} For invalid type.
87
41
  * @returns {Array} Array of directories.
88
42
  */
89
- function validateI18nDirs(dirs) {
90
- if (typeof dirs === 'undefined') {
91
- throw ReferenceError('I18n directories are missing (i18n.dirs)');
92
- }
93
- else if (!Array.isArray(dirs)) {
43
+ function validateI18nDirs(dirs = []) {
44
+ if (!Array.isArray(dirs)) {
94
45
  throw new TypeError('I18n directories must be an array (i18n.dirs)');
95
46
  }
96
47
  dirs.forEach((dir, i) => {
@@ -109,11 +60,8 @@ exports.validateI18nDirs = validateI18nDirs;
109
60
  * @throws {TypeError} For invalid type.
110
61
  * @returns {Array} Array of locales.
111
62
  */
112
- function validateI18nLocales(locales) {
113
- if (typeof locales === 'undefined') {
114
- throw ReferenceError('I18n locales are missing (i18n.locales)');
115
- }
116
- else if (!Array.isArray(locales)) {
63
+ function validateI18nLocales(locales = ['en', 'cy']) {
64
+ if (!Array.isArray(locales)) {
117
65
  throw new TypeError('I18n locales must be an array (i18n.locales)');
118
66
  }
119
67
  locales.forEach((locale, i) => {
@@ -150,7 +98,7 @@ exports.validateMountUrl = validateMountUrl;
150
98
  * @throws {TypeError} For invalid object.
151
99
  * @returns {object} Sanitised sessions object.
152
100
  */
153
- function validateSessionObject(session, cb = echo) {
101
+ function validateSessionObject(session = Object.create(null), cb = echo) {
154
102
  if (session === undefined) {
155
103
  return cb(session);
156
104
  }
@@ -168,11 +116,8 @@ exports.validateSessionObject = validateSessionObject;
168
116
  * @throws {TypeError} For invalid type.
169
117
  * @returns {Array} Array of directories.
170
118
  */
171
- function validateViews(dirs) {
172
- if (typeof dirs === 'undefined') {
173
- throw ReferenceError('View directories are missing (views)');
174
- }
175
- else if (!Array.isArray(dirs)) {
119
+ function validateViews(dirs = []) {
120
+ if (!Array.isArray(dirs)) {
176
121
  throw new TypeError('View directories must be an array (views)');
177
122
  }
178
123
  dirs.forEach((dir, i) => {
@@ -209,11 +154,8 @@ exports.validateSessionSecret = validateSessionSecret;
209
154
  * @throws {TypeError} For invalid value.
210
155
  * @returns {number} Ttl.
211
156
  */
212
- function validateSessionTtl(ttl) {
213
- if (typeof ttl === 'undefined') {
214
- throw ReferenceError('Session ttl is missing (session.ttl)');
215
- }
216
- else if (typeof ttl !== 'number') {
157
+ function validateSessionTtl(ttl = 3600) {
158
+ if (typeof ttl !== 'number') {
217
159
  throw new TypeError('Session ttl must be an integer (session.ttl)');
218
160
  }
219
161
  return ttl;
@@ -222,16 +164,13 @@ exports.validateSessionTtl = validateSessionTtl;
222
164
  /**
223
165
  * Validates and sanitises sessions name.
224
166
  *
225
- * @param {string} name Session name.
167
+ * @param {string} [name=casa-session] Session name.
226
168
  * @throws {ReferenceError} For missing value type.
227
169
  * @throws {TypeError} For invalid value.
228
170
  * @returns {string} Name.
229
171
  */
230
- function validateSessionName(name) {
231
- if (typeof name === 'undefined') {
232
- throw ReferenceError('Session name is missing (session.name)');
233
- }
234
- else if (typeof name !== 'string') {
172
+ function validateSessionName(name = 'casa-session') {
173
+ if (typeof name !== 'string') {
235
174
  throw new TypeError('Session name must be a string (session.name)');
236
175
  }
237
176
  return name;
@@ -240,16 +179,13 @@ exports.validateSessionName = validateSessionName;
240
179
  /**
241
180
  * Validates and sanitises sessions secure flag.
242
181
  *
243
- * @param {boolean} secure Session secure flag.
182
+ * @param {boolean} [secure=false] Session secure flag.
244
183
  * @throws {ReferenceError} For missing value type.
245
184
  * @throws {TypeError} For invalid value.
246
185
  * @returns {string} Name.
247
186
  */
248
- function validateSessionSecure(secure) {
249
- if (typeof secure === 'undefined') {
250
- throw ReferenceError('Session secure flag is missing (session.secure)');
251
- }
252
- else if (typeof secure !== 'boolean') {
187
+ function validateSessionSecure(secure = false) {
188
+ if (typeof secure !== 'boolean') {
253
189
  throw new TypeError('Session secure flag must be boolean (session.secure)');
254
190
  }
255
191
  return secure;
@@ -366,7 +302,7 @@ const validatePage = (page, index) => {
366
302
  throw err;
367
303
  }
368
304
  };
369
- function validatePages(pages) {
305
+ function validatePages(pages = []) {
370
306
  if (!Array.isArray(pages)) {
371
307
  throw new TypeError('Pages must be an array (pages)');
372
308
  }
@@ -418,6 +354,20 @@ function validateEvents(events) {
418
354
  return events;
419
355
  }
420
356
  exports.validateEvents = validateEvents;
357
+ /**
358
+ * Validates helmet configuration function.
359
+ *
360
+ * @param {HelmetConfigurator} helmetConfigurator Configuration function
361
+ * @returns {HelmetConfigurator} Validated configuration function
362
+ * @throws {TypeError} when passed a non-function
363
+ */
364
+ function validateHelmetConfigurator(helmetConfigurator) {
365
+ if (helmetConfigurator !== undefined && !(helmetConfigurator instanceof Function)) {
366
+ throw new TypeError('Helmet configurator must be a function');
367
+ }
368
+ return helmetConfigurator;
369
+ }
370
+ exports.validateHelmetConfigurator = validateHelmetConfigurator;
421
371
  /**
422
372
  * Ingest, validate, sanitise and manipulate configuration parameters.
423
373
  *
@@ -432,6 +382,9 @@ function ingest(config = {}) {
432
382
  dirs: validateI18nDirs(i18n.dirs),
433
383
  locales: validateI18nLocales(i18n.locales),
434
384
  })),
385
+ // !!! DEPRECATION NOTICE !!!
386
+ // This will be removed in next major version
387
+ //
435
388
  // Public URL from which the app will be served
436
389
  mountUrl: validateMountUrl(config.mountUrl),
437
390
  // Session
@@ -456,6 +409,8 @@ function ingest(config = {}) {
456
409
  plugins: validatePlugins(config.plugins),
457
410
  // Events
458
411
  events: validateEvents(config.events),
412
+ // Helmet configuration
413
+ helmetConfigurator: validateHelmetConfigurator(config.helmetConfigurator),
459
414
  };
460
415
  // Freeze to modifications
461
416
  Object.freeze(parsed);
@@ -1,90 +1,19 @@
1
1
  /**
2
- * @typedef {import('express').RequestHandler} ExpressRequestHandler
2
+ * @typedef {import('../casa').ConfigurationOptions} ConfigurationOptions
3
3
  */
4
4
  /**
5
- * @typedef {import('./index').MutableRouter} MutableRouter
5
+ * @typedef {import('../casa').ConfigurationOptions} ConfigureResult
6
6
  */
7
7
  /**
8
- * @typedef {import('./configuration-ingestor').ConfigurationOptions} ConfigurationOptions
9
- */
10
- /**
11
- * @typedef {object} ConfigureResult Result of a call to configure() function
12
- * @property {nunjucks.Environment} nunjucksEnv Nunjucks environment
13
- * @property {MutableRouter} staticRouter Router handling all static assets
14
- * @property {MutableRouter} ancillaryRouter Router handling ancillary routes
15
- * @property {MutableRouter} journeyRouter Router handling all waypoint requests
16
- * @property {ExpressRequestHandler[]} preMiddleware Middleware mounted before anything else
17
- * @property {ExpressRequestHandler[]} postMiddleware Middleware mounted after everything else
18
- * @property {ExpressRequestHandler[]} csrfMiddleware CSRF get/set middleware (useful for forms)
19
- * @property {ExpressRequestHandler} sessionMiddleware Session middleware
20
- * @property {ExpressRequestHandler[]} cookieParserMiddleware Cookie-parsing middleware
21
- * @property {ExpressRequestHandler[]} i18nMiddleware I18n preparation middleware
22
- * @property {ExpressRequestHandler} bodyParserMiddleware Body parsing middleware
23
- * @property {Function} mount Function used to mount all CASA artifacts onto an ExpressJS app
8
+ * @typedef {import('../casa').Mounter} Mounter
24
9
  */
25
10
  /**
26
11
  * Configure some middleware for use in creating a new CASA app.
27
12
  *
28
- * `mountUrl` is used to ensure the CSS content uses the correct reference to
29
- * static assets in the `govuk-frontend` module.
30
- *
31
13
  * @param {ConfigurationOptions} config Configuration options
32
14
  * @returns {ConfigureResult} Result
33
15
  */
34
16
  export default function configure(config?: ConfigurationOptions): ConfigureResult;
35
- export type ExpressRequestHandler = import('express').RequestHandler;
36
- export type MutableRouter = import('./index').MutableRouter;
37
- export type ConfigurationOptions = import('./configuration-ingestor').ConfigurationOptions;
38
- /**
39
- * Result of a call to configure() function
40
- */
41
- export type ConfigureResult = {
42
- /**
43
- * Nunjucks environment
44
- */
45
- nunjucksEnv: nunjucks.Environment;
46
- /**
47
- * Router handling all static assets
48
- */
49
- staticRouter: MutableRouter;
50
- /**
51
- * Router handling ancillary routes
52
- */
53
- ancillaryRouter: MutableRouter;
54
- /**
55
- * Router handling all waypoint requests
56
- */
57
- journeyRouter: MutableRouter;
58
- /**
59
- * Middleware mounted before anything else
60
- */
61
- preMiddleware: ExpressRequestHandler[];
62
- /**
63
- * Middleware mounted after everything else
64
- */
65
- postMiddleware: ExpressRequestHandler[];
66
- /**
67
- * CSRF get/set middleware (useful for forms)
68
- */
69
- csrfMiddleware: ExpressRequestHandler[];
70
- /**
71
- * Session middleware
72
- */
73
- sessionMiddleware: ExpressRequestHandler;
74
- /**
75
- * Cookie-parsing middleware
76
- */
77
- cookieParserMiddleware: ExpressRequestHandler[];
78
- /**
79
- * I18n preparation middleware
80
- */
81
- i18nMiddleware: ExpressRequestHandler[];
82
- /**
83
- * Body parsing middleware
84
- */
85
- bodyParserMiddleware: ExpressRequestHandler;
86
- /**
87
- * Function used to mount all CASA artifacts onto an ExpressJS app
88
- */
89
- mount: Function;
90
- };
17
+ export type ConfigurationOptions = import('../casa').ConfigurationOptions;
18
+ export type ConfigureResult = import('../casa').ConfigurationOptions;
19
+ export type Mounter = import('../casa').Mounter;