@dwp/govuk-casa 9.0.0 → 9.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.
- package/README.md +9 -9
- package/dist/assets/css/casa.css +1 -1
- package/dist/assets/css/casa.css.map +1 -1
- package/dist/casa.d.ts +122 -95
- package/dist/casa.js +119 -86
- package/dist/casa.js.map +1 -1
- package/dist/lib/CasaTemplateLoader.d.ts +4 -4
- package/dist/lib/CasaTemplateLoader.js +16 -16
- package/dist/lib/CasaTemplateLoader.js.map +1 -1
- package/dist/lib/JourneyContext.d.ts +58 -40
- package/dist/lib/JourneyContext.js +132 -75
- package/dist/lib/JourneyContext.js.map +1 -1
- package/dist/lib/MutableRouter.d.ts +40 -41
- package/dist/lib/MutableRouter.js +64 -71
- package/dist/lib/MutableRouter.js.map +1 -1
- package/dist/lib/Plan.d.ts +29 -26
- package/dist/lib/Plan.js +85 -71
- package/dist/lib/Plan.js.map +1 -1
- package/dist/lib/ValidationError.d.ts +16 -15
- package/dist/lib/ValidationError.js +21 -20
- package/dist/lib/ValidationError.js.map +1 -1
- package/dist/lib/ValidatorFactory.d.ts +15 -13
- package/dist/lib/ValidatorFactory.js +14 -12
- package/dist/lib/ValidatorFactory.js.map +1 -1
- package/dist/lib/configuration-ingestor.d.ts +37 -40
- package/dist/lib/configuration-ingestor.js +93 -93
- package/dist/lib/configuration-ingestor.js.map +1 -1
- package/dist/lib/configure.d.ts +6 -6
- package/dist/lib/configure.js +14 -12
- package/dist/lib/configure.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -3
- package/dist/lib/constants.js +9 -11
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/context-id-generators.d.ts +3 -5
- package/dist/lib/context-id-generators.js +7 -6
- package/dist/lib/context-id-generators.js.map +1 -1
- package/dist/lib/end-session.d.ts +4 -4
- package/dist/lib/end-session.js +5 -5
- package/dist/lib/field.d.ts +20 -18
- package/dist/lib/field.js +35 -48
- package/dist/lib/field.js.map +1 -1
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/logger.d.ts +7 -6
- package/dist/lib/logger.js +7 -7
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mount.d.ts +5 -5
- package/dist/lib/mount.js +11 -10
- package/dist/lib/mount.js.map +1 -1
- package/dist/lib/nunjucks-filters.d.ts +10 -12
- package/dist/lib/nunjucks-filters.js +35 -35
- package/dist/lib/nunjucks-filters.js.map +1 -1
- package/dist/lib/nunjucks.d.ts +7 -5
- package/dist/lib/nunjucks.js +10 -8
- package/dist/lib/nunjucks.js.map +1 -1
- package/dist/lib/utils.d.ts +19 -19
- package/dist/lib/utils.js +62 -55
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validators/dateObject.d.ts +29 -22
- package/dist/lib/validators/dateObject.js +58 -49
- package/dist/lib/validators/dateObject.js.map +1 -1
- package/dist/lib/validators/email.d.ts +4 -4
- package/dist/lib/validators/email.js +4 -4
- package/dist/lib/validators/inArray.d.ts +4 -4
- package/dist/lib/validators/inArray.js +7 -8
- package/dist/lib/validators/inArray.js.map +1 -1
- package/dist/lib/validators/index.d.ts +10 -10
- package/dist/lib/validators/index.js +1 -3
- package/dist/lib/validators/index.js.map +1 -1
- package/dist/lib/validators/nino.d.ts +9 -8
- package/dist/lib/validators/nino.js +14 -10
- package/dist/lib/validators/nino.js.map +1 -1
- package/dist/lib/validators/postalAddressObject.d.ts +37 -24
- package/dist/lib/validators/postalAddressObject.js +65 -46
- package/dist/lib/validators/postalAddressObject.js.map +1 -1
- package/dist/lib/validators/range.d.ts +12 -8
- package/dist/lib/validators/range.js +11 -9
- package/dist/lib/validators/range.js.map +1 -1
- package/dist/lib/validators/regex.d.ts +4 -4
- package/dist/lib/validators/regex.js +5 -5
- package/dist/lib/validators/required.d.ts +6 -6
- package/dist/lib/validators/required.js +9 -11
- package/dist/lib/validators/required.js.map +1 -1
- package/dist/lib/validators/strlen.d.ts +12 -8
- package/dist/lib/validators/strlen.js +13 -11
- package/dist/lib/validators/strlen.js.map +1 -1
- package/dist/lib/validators/wordCount.d.ts +12 -8
- package/dist/lib/validators/wordCount.js +15 -11
- package/dist/lib/validators/wordCount.js.map +1 -1
- package/dist/lib/waypoint-url.d.ts +16 -13
- package/dist/lib/waypoint-url.js +39 -36
- package/dist/lib/waypoint-url.js.map +1 -1
- package/dist/middleware/body-parser.d.ts +1 -1
- package/dist/middleware/body-parser.js +6 -6
- package/dist/middleware/body-parser.js.map +1 -1
- package/dist/middleware/data.d.ts +1 -1
- package/dist/middleware/data.js +8 -7
- package/dist/middleware/data.js.map +1 -1
- package/dist/middleware/gather-fields.d.ts +2 -2
- package/dist/middleware/gather-fields.js +6 -4
- package/dist/middleware/gather-fields.js.map +1 -1
- package/dist/middleware/i18n.js +13 -15
- package/dist/middleware/i18n.js.map +1 -1
- package/dist/middleware/post.js +30 -18
- package/dist/middleware/post.js.map +1 -1
- package/dist/middleware/pre.d.ts +2 -2
- package/dist/middleware/pre.js +46 -27
- package/dist/middleware/pre.js.map +1 -1
- package/dist/middleware/progress-journey.d.ts +1 -1
- package/dist/middleware/progress-journey.js +5 -5
- package/dist/middleware/progress-journey.js.map +1 -1
- package/dist/middleware/sanitise-fields.d.ts +1 -1
- package/dist/middleware/sanitise-fields.js +13 -11
- package/dist/middleware/sanitise-fields.js.map +1 -1
- package/dist/middleware/serve-first-waypoint.d.ts +3 -3
- package/dist/middleware/serve-first-waypoint.js +8 -6
- package/dist/middleware/serve-first-waypoint.js.map +1 -1
- package/dist/middleware/session.js +14 -11
- package/dist/middleware/session.js.map +1 -1
- package/dist/middleware/skip-waypoint.d.ts +1 -1
- package/dist/middleware/skip-waypoint.js +5 -9
- package/dist/middleware/skip-waypoint.js.map +1 -1
- package/dist/middleware/steer-journey.d.ts +1 -1
- package/dist/middleware/steer-journey.js +16 -14
- package/dist/middleware/steer-journey.js.map +1 -1
- package/dist/middleware/strip-proxy-path.d.ts +1 -1
- package/dist/middleware/strip-proxy-path.js +3 -3
- package/dist/middleware/strip-proxy-path.js.map +1 -1
- package/dist/middleware/validate-fields.d.ts +1 -1
- package/dist/middleware/validate-fields.js +2 -5
- package/dist/middleware/validate-fields.js.map +1 -1
- package/dist/routes/ancillary.d.ts +3 -3
- package/dist/routes/ancillary.js +4 -4
- package/dist/routes/ancillary.js.map +1 -1
- package/dist/routes/journey.d.ts +2 -2
- package/dist/routes/journey.js +91 -39
- package/dist/routes/journey.js.map +1 -1
- package/dist/routes/static.d.ts +7 -5
- package/dist/routes/static.js +20 -19
- package/dist/routes/static.js.map +1 -1
- package/package.json +20 -19
- package/src/casa.js +133 -100
- package/src/lib/CasaTemplateLoader.js +24 -19
- package/src/lib/JourneyContext.js +190 -107
- package/src/lib/MutableRouter.js +72 -74
- package/src/lib/Plan.js +145 -97
- package/src/lib/ValidationError.js +25 -21
- package/src/lib/ValidatorFactory.js +17 -13
- package/src/lib/configuration-ingestor.js +147 -110
- package/src/lib/configure.js +34 -32
- package/src/lib/constants.js +9 -11
- package/src/lib/context-id-generators.js +40 -43
- package/src/lib/end-session.js +6 -6
- package/src/lib/field.js +69 -58
- package/src/lib/index.js +12 -12
- package/src/lib/logger.js +9 -9
- package/src/lib/mount.js +70 -74
- package/src/lib/nunjucks-filters.js +56 -59
- package/src/lib/nunjucks.js +23 -18
- package/src/lib/utils.js +78 -57
- package/src/lib/validators/dateObject.js +71 -60
- package/src/lib/validators/email.js +8 -8
- package/src/lib/validators/inArray.js +10 -11
- package/src/lib/validators/index.js +12 -14
- package/src/lib/validators/nino.js +29 -15
- package/src/lib/validators/postalAddressObject.js +87 -63
- package/src/lib/validators/range.js +14 -12
- package/src/lib/validators/regex.js +8 -8
- package/src/lib/validators/required.js +16 -16
- package/src/lib/validators/strlen.js +16 -14
- package/src/lib/validators/wordCount.js +22 -14
- package/src/lib/waypoint-url.js +64 -46
- package/src/middleware/body-parser.js +10 -10
- package/src/middleware/csrf.js +1 -1
- package/src/middleware/data.js +28 -24
- package/src/middleware/gather-fields.js +10 -9
- package/src/middleware/i18n.js +35 -37
- package/src/middleware/post.js +41 -21
- package/src/middleware/pre.js +62 -41
- package/src/middleware/progress-journey.js +32 -18
- package/src/middleware/sanitise-fields.js +43 -20
- package/src/middleware/serve-first-waypoint.js +14 -12
- package/src/middleware/session.js +74 -61
- package/src/middleware/skip-waypoint.js +8 -15
- package/src/middleware/steer-journey.js +40 -28
- package/src/middleware/strip-proxy-path.js +8 -7
- package/src/middleware/validate-fields.js +5 -12
- package/src/routes/ancillary.js +5 -7
- package/src/routes/journey.js +159 -85
- package/src/routes/static.js +62 -29
- package/views/casa/components/character-count/README.md +2 -2
- package/views/casa/components/checkboxes/README.md +6 -6
- package/views/casa/components/date-input/README.md +7 -7
- package/views/casa/components/input/README.md +2 -2
- package/views/casa/components/journey-form/README.md +33 -14
- package/views/casa/components/postal-address-object/README.md +4 -4
- package/views/casa/components/radios/README.md +6 -6
- package/views/casa/components/select/README.md +6 -6
- package/views/casa/components/textarea/README.md +2 -2
- package/views/casa/layouts/main.njk +2 -1
package/src/lib/MutableRouter.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
/* eslint-disable sonarjs/no-duplicate-string,class-methods-use-this */
|
|
2
|
-
import { Router } from
|
|
2
|
+
import { Router } from "express";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @memberof module:@dwp/govuk-casa
|
|
6
|
-
*/
|
|
4
|
+
/** @memberof module:@dwp/govuk-casa */
|
|
7
5
|
export default class MutableRouter {
|
|
8
|
-
/**
|
|
9
|
-
* @type {Array}
|
|
10
|
-
*/
|
|
6
|
+
/** @type {Array} */
|
|
11
7
|
#stack;
|
|
12
8
|
|
|
13
|
-
/**
|
|
14
|
-
* @type {Router}
|
|
15
|
-
*/
|
|
9
|
+
/** @type {Router} */
|
|
16
10
|
#router;
|
|
17
11
|
|
|
18
|
-
/**
|
|
19
|
-
* @type {boolean}
|
|
20
|
-
*/
|
|
12
|
+
/** @type {boolean} */
|
|
21
13
|
#sealed;
|
|
22
14
|
|
|
23
15
|
/**
|
|
@@ -35,7 +27,7 @@ export default class MutableRouter {
|
|
|
35
27
|
|
|
36
28
|
#append(method, path, ...callbacks) {
|
|
37
29
|
if (this.#sealed) {
|
|
38
|
-
throw new Error(
|
|
30
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
39
31
|
}
|
|
40
32
|
|
|
41
33
|
this.#stack.push({
|
|
@@ -47,7 +39,7 @@ export default class MutableRouter {
|
|
|
47
39
|
|
|
48
40
|
#prepend(method, path, ...callbacks) {
|
|
49
41
|
if (this.#sealed) {
|
|
50
|
-
throw new Error(
|
|
42
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
this.#stack.splice(0, 0, {
|
|
@@ -61,10 +53,11 @@ export default class MutableRouter {
|
|
|
61
53
|
// given path
|
|
62
54
|
#replace(method, path, ...callbacks) {
|
|
63
55
|
if (this.#sealed) {
|
|
64
|
-
throw new Error(
|
|
56
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
65
57
|
}
|
|
66
58
|
|
|
67
|
-
const finder = (command) =>
|
|
59
|
+
const finder = (command) =>
|
|
60
|
+
`${command.method}|${command.path}` === `${method}|${path}`;
|
|
68
61
|
const index = this.#stack.findIndex(finder);
|
|
69
62
|
|
|
70
63
|
if (index > -1) {
|
|
@@ -74,7 +67,9 @@ export default class MutableRouter {
|
|
|
74
67
|
args: [path, ...callbacks],
|
|
75
68
|
});
|
|
76
69
|
|
|
77
|
-
this.#stack = this.#stack.filter(
|
|
70
|
+
this.#stack = this.#stack.filter(
|
|
71
|
+
(command, idx) => idx <= index || !finder(command),
|
|
72
|
+
);
|
|
78
73
|
}
|
|
79
74
|
}
|
|
80
75
|
|
|
@@ -105,67 +100,67 @@ export default class MutableRouter {
|
|
|
105
100
|
/**
|
|
106
101
|
* Prepend middleware function(s) using the `all()` method.
|
|
107
102
|
*
|
|
108
|
-
* @param {string | Function} path
|
|
109
|
-
* @param
|
|
103
|
+
* @param {string | Function} path Route path or middleware function
|
|
104
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
110
105
|
* @returns {void}
|
|
111
106
|
*/
|
|
112
107
|
prependAll(path, ...callbacks) {
|
|
113
|
-
this.#prepend(
|
|
108
|
+
this.#prepend("all", path, ...callbacks);
|
|
114
109
|
}
|
|
115
110
|
|
|
116
111
|
/**
|
|
117
112
|
* Prepend middleware function(s) using the `get()` method.
|
|
118
113
|
*
|
|
119
|
-
* @param {string | Function} path
|
|
120
|
-
* @param
|
|
114
|
+
* @param {string | Function} path Route path or middleware function
|
|
115
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
121
116
|
* @returns {void}
|
|
122
117
|
*/
|
|
123
118
|
prependGet(path, ...callbacks) {
|
|
124
|
-
this.#prepend(
|
|
119
|
+
this.#prepend("get", path, ...callbacks);
|
|
125
120
|
}
|
|
126
121
|
|
|
127
122
|
/**
|
|
128
123
|
* Prepend middleware function(s) using the `post()` method.
|
|
129
124
|
*
|
|
130
|
-
* @param {string | Function} path
|
|
131
|
-
* @param
|
|
125
|
+
* @param {string | Function} path Route path or middleware function
|
|
126
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
132
127
|
* @returns {void}
|
|
133
128
|
*/
|
|
134
129
|
prependPost(path, ...callbacks) {
|
|
135
|
-
this.#prepend(
|
|
130
|
+
this.#prepend("post", path, ...callbacks);
|
|
136
131
|
}
|
|
137
132
|
|
|
138
133
|
/**
|
|
139
134
|
* Prepend middleware function(s) using the `delete()` method.
|
|
140
135
|
*
|
|
141
|
-
* @param {string | Function} path
|
|
142
|
-
* @param
|
|
136
|
+
* @param {string | Function} path Route path or middleware function
|
|
137
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
143
138
|
* @returns {void}
|
|
144
139
|
*/
|
|
145
140
|
prependDelete(path, ...callbacks) {
|
|
146
|
-
this.#prepend(
|
|
141
|
+
this.#prepend("delete", path, ...callbacks);
|
|
147
142
|
}
|
|
148
143
|
|
|
149
144
|
/**
|
|
150
145
|
* Prepend middleware function(s) using the `put()` method.
|
|
151
146
|
*
|
|
152
|
-
* @param {string | Function} path
|
|
153
|
-
* @param
|
|
147
|
+
* @param {string | Function} path Route path or middleware function
|
|
148
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
154
149
|
* @returns {void}
|
|
155
150
|
*/
|
|
156
151
|
prependPut(path, ...callbacks) {
|
|
157
|
-
this.#prepend(
|
|
152
|
+
this.#prepend("put", path, ...callbacks);
|
|
158
153
|
}
|
|
159
154
|
|
|
160
155
|
/**
|
|
161
156
|
* Prepend middleware function(s) using the `use()` method.
|
|
162
157
|
*
|
|
163
|
-
* @param {string | Function} path
|
|
164
|
-
* @param
|
|
158
|
+
* @param {string | Function} path Route path or middleware function
|
|
159
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
165
160
|
* @returns {void}
|
|
166
161
|
*/
|
|
167
162
|
prependUse(path, ...callbacks) {
|
|
168
|
-
this.#prepend(
|
|
163
|
+
this.#prepend("use", path, ...callbacks);
|
|
169
164
|
}
|
|
170
165
|
|
|
171
166
|
/* -------------------------------------------------------------- replacers */
|
|
@@ -173,67 +168,68 @@ export default class MutableRouter {
|
|
|
173
168
|
/**
|
|
174
169
|
* Replace middleware function(s) that were mounted using the `all()` method.
|
|
175
170
|
*
|
|
176
|
-
* @param {string | Function} path
|
|
177
|
-
* @param
|
|
171
|
+
* @param {string | Function} path Route path or middleware function
|
|
172
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
178
173
|
* @returns {void}
|
|
179
174
|
*/
|
|
180
175
|
replaceAll(path, ...callbacks) {
|
|
181
|
-
this.#replace(
|
|
176
|
+
this.#replace("all", path, ...callbacks);
|
|
182
177
|
}
|
|
183
178
|
|
|
184
179
|
/**
|
|
185
180
|
* Replace middleware function(s) that were mounted using the `get()` method.
|
|
186
181
|
*
|
|
187
|
-
* @param {string | Function} path
|
|
188
|
-
* @param
|
|
182
|
+
* @param {string | Function} path Route path or middleware function
|
|
183
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
189
184
|
* @returns {void}
|
|
190
185
|
*/
|
|
191
186
|
replaceGet(path, ...callbacks) {
|
|
192
|
-
this.#replace(
|
|
187
|
+
this.#replace("get", path, ...callbacks);
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
/**
|
|
196
191
|
* Replace middleware function(s) that were mounted using the `post()` method.
|
|
197
192
|
*
|
|
198
|
-
* @param {string | Function} path
|
|
199
|
-
* @param
|
|
193
|
+
* @param {string | Function} path Route path or middleware function
|
|
194
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
200
195
|
* @returns {void}
|
|
201
196
|
*/
|
|
202
197
|
replacePost(path, ...callbacks) {
|
|
203
|
-
this.#replace(
|
|
198
|
+
this.#replace("post", path, ...callbacks);
|
|
204
199
|
}
|
|
205
200
|
|
|
206
201
|
/**
|
|
207
|
-
* Replace middleware function(s) that were mounted using the `delete()`
|
|
202
|
+
* Replace middleware function(s) that were mounted using the `delete()`
|
|
203
|
+
* method.
|
|
208
204
|
*
|
|
209
|
-
* @param {string | Function} path
|
|
210
|
-
* @param
|
|
205
|
+
* @param {string | Function} path Route path or middleware function
|
|
206
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
211
207
|
* @returns {void}
|
|
212
208
|
*/
|
|
213
209
|
replaceDelete(path, ...callbacks) {
|
|
214
|
-
this.#replace(
|
|
210
|
+
this.#replace("delete", path, ...callbacks);
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
/**
|
|
218
214
|
* Replace middleware function(s) that were mounted using the `put()` method.
|
|
219
215
|
*
|
|
220
|
-
* @param {string | Function} path
|
|
221
|
-
* @param
|
|
216
|
+
* @param {string | Function} path Route path or middleware function
|
|
217
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
222
218
|
* @returns {void}
|
|
223
219
|
*/
|
|
224
220
|
replacePut(path, ...callbacks) {
|
|
225
|
-
this.#replace(
|
|
221
|
+
this.#replace("put", path, ...callbacks);
|
|
226
222
|
}
|
|
227
223
|
|
|
228
224
|
/**
|
|
229
225
|
* Replace middleware function(s) that were mounted using the `use()` method.
|
|
230
226
|
*
|
|
231
|
-
* @param {string | Function} path
|
|
232
|
-
* @param
|
|
227
|
+
* @param {string | Function} path Route path or middleware function
|
|
228
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
233
229
|
* @returns {void}
|
|
234
230
|
*/
|
|
235
231
|
replaceUse(path, ...callbacks) {
|
|
236
|
-
this.#replace(
|
|
232
|
+
this.#replace("use", path, ...callbacks);
|
|
237
233
|
}
|
|
238
234
|
|
|
239
235
|
/* ---------------------------------------------- express.Router() wrappers */
|
|
@@ -241,70 +237,72 @@ export default class MutableRouter {
|
|
|
241
237
|
/**
|
|
242
238
|
* Append middleware function(s) using the `all()` method.
|
|
243
239
|
*
|
|
244
|
-
* @param {string | Function} path
|
|
245
|
-
* @param
|
|
240
|
+
* @param {string | Function} path Route path or middleware function
|
|
241
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
246
242
|
* @returns {void}
|
|
247
243
|
*/
|
|
248
244
|
all(path, ...callbacks) {
|
|
249
|
-
this.#append(
|
|
245
|
+
this.#append("all", path, ...callbacks);
|
|
250
246
|
}
|
|
251
247
|
|
|
252
248
|
/**
|
|
253
249
|
* Append middleware function(s) using the `get()` method.
|
|
254
250
|
*
|
|
255
|
-
* @param {string | Function} path
|
|
256
|
-
* @param
|
|
251
|
+
* @param {string | Function} path Route path or middleware function
|
|
252
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
257
253
|
* @returns {void}
|
|
258
254
|
*/
|
|
259
255
|
get(path, ...callbacks) {
|
|
260
|
-
this.#append(
|
|
256
|
+
this.#append("get", path, ...callbacks);
|
|
261
257
|
}
|
|
262
258
|
|
|
263
259
|
/**
|
|
264
260
|
* Append middleware function(s) using the `post()` method.
|
|
265
261
|
*
|
|
266
|
-
* @param {string | Function} path
|
|
267
|
-
* @param
|
|
262
|
+
* @param {string | Function} path Route path or middleware function
|
|
263
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
268
264
|
* @returns {void}
|
|
269
265
|
*/
|
|
270
266
|
post(path, ...callbacks) {
|
|
271
|
-
this.#append(
|
|
267
|
+
this.#append("post", path, ...callbacks);
|
|
272
268
|
}
|
|
273
269
|
|
|
274
270
|
/**
|
|
275
271
|
* Append middleware function(s) using the `delete()` method.
|
|
276
272
|
*
|
|
277
|
-
* @param {string | Function} path
|
|
278
|
-
* @param
|
|
273
|
+
* @param {string | Function} path Route path or middleware function
|
|
274
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
279
275
|
* @returns {void}
|
|
280
276
|
*/
|
|
281
277
|
delete(path, ...callbacks) {
|
|
282
|
-
this.#append(
|
|
278
|
+
this.#append("delete", path, ...callbacks);
|
|
283
279
|
}
|
|
284
280
|
|
|
285
281
|
/**
|
|
286
282
|
* Append middleware function(s) using the `put()` method.
|
|
287
283
|
*
|
|
288
|
-
* @param {string | Function} path
|
|
289
|
-
* @param
|
|
284
|
+
* @param {string | Function} path Route path or middleware function
|
|
285
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
290
286
|
* @returns {void}
|
|
291
287
|
*/
|
|
292
288
|
put(path, ...callbacks) {
|
|
293
|
-
this.#append(
|
|
289
|
+
this.#append("put", path, ...callbacks);
|
|
294
290
|
}
|
|
295
291
|
|
|
296
292
|
/**
|
|
297
293
|
* Append middleware function(s) using the `use()` method.
|
|
298
294
|
*
|
|
299
|
-
* @param {string | Function} path
|
|
300
|
-
* @param
|
|
295
|
+
* @param {string | Function} path Route path or middleware function
|
|
296
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
301
297
|
* @returns {void}
|
|
302
298
|
*/
|
|
303
299
|
use(path, ...callbacks) {
|
|
304
|
-
this.#append(
|
|
300
|
+
this.#append("use", path, ...callbacks);
|
|
305
301
|
}
|
|
306
302
|
|
|
307
303
|
route() {
|
|
308
|
-
throw new Error(
|
|
304
|
+
throw new Error(
|
|
305
|
+
"route() method is not supported on MutableRouter. Use verb methods for now.",
|
|
306
|
+
);
|
|
309
307
|
}
|
|
310
308
|
}
|