hof 22.8.4-unhandled-error-fix-beta.1 → 22.9.0-beta
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/CHANGELOG.md +16 -0
- package/README.md +30 -0
- package/config/hof-defaults.js +6 -1
- package/frontend/template-partials/views/layout.html +2 -8
- package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -3
- package/hof-22.9.0.tgz +0 -0
- package/lib/settings.js +1 -0
- package/model/index.js +1 -1
- package/package/.eslintignore +1 -0
- package/package/CHANGELOG.md +232 -0
- package/package/LICENSE +21 -0
- package/package/README.md +1887 -0
- package/package/bin/hof-build +10 -0
- package/package/bin/hof-transpiler +12 -0
- package/package/build/helpers/importer.js +29 -0
- package/package/build/helpers/local.js +35 -0
- package/package/build/helpers/resolver/import.js +32 -0
- package/package/build/helpers/resolver/nearest-package-root.js +33 -0
- package/package/build/helpers/resolver/package.js +29 -0
- package/package/build/helpers/resolver.js +16 -0
- package/package/build/index.js +49 -0
- package/package/build/lib/env.js +36 -0
- package/package/build/lib/mkdir.js +9 -0
- package/package/build/lib/run.js +17 -0
- package/package/build/lib/spawn.js +18 -0
- package/package/build/tasks/browserify/compress.js +15 -0
- package/package/build/tasks/browserify/index.js +48 -0
- package/package/build/tasks/build/index.js +6 -0
- package/package/build/tasks/images/index.js +27 -0
- package/package/build/tasks/index.js +8 -0
- package/package/build/tasks/sass/index.js +67 -0
- package/package/build/tasks/translate/index.js +20 -0
- package/package/build/tasks/watch/index.js +161 -0
- package/package/components/address-lookup/default-model.js +76 -0
- package/package/components/address-lookup/defaults.js +25 -0
- package/package/components/address-lookup/index.js +251 -0
- package/package/components/address-lookup/templates/address-lookup.html +14 -0
- package/package/components/address-lookup/templates/address.html +22 -0
- package/package/components/address-lookup/templates/postcode.html +9 -0
- package/package/components/clear-session/Readme.md +46 -0
- package/package/components/clear-session/index.js +26 -0
- package/package/components/combine-and-loop-fields/Readme.md +42 -0
- package/package/components/combine-and-loop-fields/index.js +156 -0
- package/package/components/date/fields.js +16 -0
- package/package/components/date/index.js +172 -0
- package/package/components/date/templates/date.html +20 -0
- package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
- package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
- package/package/components/emailer/assets/images/spacer.gif +0 -0
- package/package/components/emailer/email-service.js +51 -0
- package/package/components/emailer/emailer.js +53 -0
- package/package/components/emailer/index.js +74 -0
- package/package/components/emailer/transports/debug.js +74 -0
- package/package/components/emailer/transports/index.js +8 -0
- package/package/components/emailer/transports/ses.js +36 -0
- package/package/components/emailer/transports/smtp.js +26 -0
- package/package/components/emailer/transports/stub.js +5 -0
- package/package/components/emailer/views/layout.html +63 -0
- package/package/components/homeoffice-countries/index.js +22 -0
- package/package/components/index.js +13 -0
- package/package/components/notify/index.js +62 -0
- package/package/components/notify/notify.js +51 -0
- package/package/components/session-timeout-warning/index.js +67 -0
- package/package/components/summary/index.js +237 -0
- package/package/config/builder-defaults.js +45 -0
- package/package/config/component-defaults.js +13 -0
- package/package/config/hof-defaults.js +65 -0
- package/package/config/rate-limits.js +20 -0
- package/package/config/sanitisation-rules.js +32 -0
- package/package/controller/base-controller.js +296 -0
- package/package/controller/behaviour-hooks.js +51 -0
- package/package/controller/behaviour-session.js +64 -0
- package/package/controller/controller.js +258 -0
- package/package/controller/deprecate-error.js +10 -0
- package/package/controller/formatting/formatters.js +70 -0
- package/package/controller/formatting/index.js +32 -0
- package/package/controller/index.js +17 -0
- package/package/controller/validation/email.js +30 -0
- package/package/controller/validation/index.js +101 -0
- package/package/controller/validation/validators.js +181 -0
- package/package/controller/validation-error.js +14 -0
- package/package/frontend/govuk-template/build/config.js +24 -0
- package/package/frontend/govuk-template/build/govuk_template.html +102 -0
- package/package/frontend/govuk-template/build/index.js +23 -0
- package/package/frontend/govuk-template/govuk_template_generated.html +102 -0
- package/package/frontend/govuk-template/index.js +29 -0
- package/package/frontend/index.js +9 -0
- package/package/frontend/template-mixins/mixins/helpers.js +103 -0
- package/package/frontend/template-mixins/mixins/index.js +37 -0
- package/package/frontend/template-mixins/mixins/render.js +12 -0
- package/package/frontend/template-mixins/mixins/template-mixins.js +520 -0
- package/package/frontend/template-mixins/partials/forms/checkbox-group.html +47 -0
- package/package/frontend/template-mixins/partials/forms/checkbox.html +16 -0
- package/package/frontend/template-mixins/partials/forms/input-submit.html +1 -0
- package/package/frontend/template-mixins/partials/forms/input-text-date.html +37 -0
- package/package/frontend/template-mixins/partials/forms/input-text-group.html +45 -0
- package/package/frontend/template-mixins/partials/forms/option-group.html +43 -0
- package/package/frontend/template-mixins/partials/forms/select.html +17 -0
- package/package/frontend/template-mixins/partials/forms/textarea-group.html +37 -0
- package/package/frontend/template-mixins/partials/mixins/panel.html +4 -0
- package/package/frontend/template-partials/index.js +9 -0
- package/package/frontend/template-partials/translations/index.js +26 -0
- package/package/frontend/template-partials/translations/src/cy/base.json +4 -0
- package/package/frontend/template-partials/translations/src/cy/buttons.json +6 -0
- package/package/frontend/template-partials/translations/src/cy/cookies.json +104 -0
- package/package/frontend/template-partials/translations/src/cy/errorlist.json +6 -0
- package/package/frontend/template-partials/translations/src/cy/errors.json +18 -0
- package/package/frontend/template-partials/translations/src/cy/terms.json +28 -0
- package/package/frontend/template-partials/translations/src/en/accessibility.json +43 -0
- package/package/frontend/template-partials/translations/src/en/base.json +5 -0
- package/package/frontend/template-partials/translations/src/en/buttons.json +10 -0
- package/package/frontend/template-partials/translations/src/en/cookies.json +116 -0
- package/package/frontend/template-partials/translations/src/en/errorlist.json +7 -0
- package/package/frontend/template-partials/translations/src/en/errors.json +35 -0
- package/package/frontend/template-partials/translations/src/en/exit.json +5 -0
- package/package/frontend/template-partials/translations/src/en/fields.json +5 -0
- package/package/frontend/template-partials/translations/src/en/journey.json +6 -0
- package/package/frontend/template-partials/translations/src/en/save-and-exit.json +4 -0
- package/package/frontend/template-partials/translations/src/en/terms.json +28 -0
- package/package/frontend/template-partials/views/404.html +9 -0
- package/package/frontend/template-partials/views/accessibility.html +55 -0
- package/package/frontend/template-partials/views/confirm.html +8 -0
- package/package/frontend/template-partials/views/confirmation.html +19 -0
- package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
- package/package/frontend/template-partials/views/cookie-error.html +1 -0
- package/package/frontend/template-partials/views/cookies.html +84 -0
- package/package/frontend/template-partials/views/email/data-row.html +4 -0
- package/package/frontend/template-partials/views/email/formatted.html +12 -0
- package/package/frontend/template-partials/views/email/layout.html +63 -0
- package/package/frontend/template-partials/views/email/raw.html +11 -0
- package/package/frontend/template-partials/views/email/section-row.html +3 -0
- package/package/frontend/template-partials/views/error.html +20 -0
- package/package/frontend/template-partials/views/exit.html +9 -0
- package/package/frontend/template-partials/views/feedback-submitted.html +11 -0
- package/package/frontend/template-partials/views/layout.html +55 -0
- package/package/frontend/template-partials/views/partials/analytics-table.html +25 -0
- package/package/frontend/template-partials/views/partials/back.html +5 -0
- package/package/frontend/template-partials/views/partials/bullet-list.html +7 -0
- package/package/frontend/template-partials/views/partials/confirmation-alert.html +6 -0
- package/package/frontend/template-partials/views/partials/continue.html +5 -0
- package/package/frontend/template-partials/views/partials/cookie-banner.html +29 -0
- package/package/frontend/template-partials/views/partials/cookie-notification.html +4 -0
- package/package/frontend/template-partials/views/partials/cookie-settings-button.html +1 -0
- package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +8 -0
- package/package/frontend/template-partials/views/partials/details-summary.html +8 -0
- package/package/frontend/template-partials/views/partials/external-link.html +1 -0
- package/package/frontend/template-partials/views/partials/form.html +10 -0
- package/package/frontend/template-partials/views/partials/gatag.html +60 -0
- package/package/frontend/template-partials/views/partials/head.html +31 -0
- package/package/frontend/template-partials/views/partials/heading.html +11 -0
- package/package/frontend/template-partials/views/partials/items-table.html +32 -0
- package/package/frontend/template-partials/views/partials/maincontent-left.html +10 -0
- package/package/frontend/template-partials/views/partials/navigation.html +8 -0
- package/package/frontend/template-partials/views/partials/page.html +23 -0
- package/package/frontend/template-partials/views/partials/panel-indent.html +3 -0
- package/package/frontend/template-partials/views/partials/session-cookies-table.html +28 -0
- package/package/frontend/template-partials/views/partials/session-timeout-warning.html +38 -0
- package/package/frontend/template-partials/views/partials/summary-table-row.html +14 -0
- package/package/frontend/template-partials/views/partials/summary-table.html +8 -0
- package/package/frontend/template-partials/views/partials/table.html +18 -0
- package/package/frontend/template-partials/views/partials/validation-list.html +3 -0
- package/package/frontend/template-partials/views/partials/validation-summary.html +25 -0
- package/package/frontend/template-partials/views/partials/warn.html +7 -0
- package/package/frontend/template-partials/views/rate-limit-error.html +10 -0
- package/package/frontend/template-partials/views/save-and-exit.html +17 -0
- package/package/frontend/template-partials/views/service-unavailable.html +13 -0
- package/package/frontend/template-partials/views/session-timeout.html +7 -0
- package/package/frontend/template-partials/views/step.html +14 -0
- package/package/frontend/template-partials/views/terms.html +26 -0
- package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +145 -0
- package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +121 -0
- package/package/frontend/themes/gov-uk/client-js/index.js +27 -0
- package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +348 -0
- package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +19 -0
- package/package/frontend/themes/gov-uk/index.js +9 -0
- package/package/frontend/themes/gov-uk/styles/_base.scss +17 -0
- package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +155 -0
- package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +111 -0
- package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +33 -0
- package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +23 -0
- package/package/frontend/themes/gov-uk/styles/_helpers.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/_layout.scss +125 -0
- package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +27 -0
- package/package/frontend/themes/gov-uk/styles/_pdf.scss +42 -0
- package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +121 -0
- package/package/frontend/themes/gov-uk/styles/_typography.scss +27 -0
- package/package/frontend/themes/gov-uk/styles/_variables.scss +11 -0
- package/package/frontend/themes/gov-uk/styles/govuk.scss +43 -0
- package/package/frontend/themes/gov-uk/styles/mixins.scss +16 -0
- package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +73 -0
- package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +8 -0
- package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +20 -0
- package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +17 -0
- package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +51 -0
- package/package/frontend/themes/index.js +5 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
- package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
- package/package/frontend/toolkit/assets/javascript/character-count.js +99 -0
- package/package/frontend/toolkit/assets/javascript/form-focus.js +101 -0
- package/package/frontend/toolkit/assets/javascript/helpers.js +177 -0
- package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +72 -0
- package/package/frontend/toolkit/assets/javascript/validation.js +71 -0
- package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +189 -0
- package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +39 -0
- package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +6 -0
- package/package/frontend/toolkit/assets/stylesheets/_base.scss +17 -0
- package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/_layout.scss +118 -0
- package/package/frontend/toolkit/assets/stylesheets/_typography.scss +27 -0
- package/package/frontend/toolkit/assets/stylesheets/_variables.scss +11 -0
- package/package/frontend/toolkit/assets/stylesheets/app.scss +30 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +47 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +38 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +175 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +167 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +39 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +67 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +40 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +29 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +33 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +33 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +63 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +39 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +63 -0
- package/package/frontend/toolkit/assets/stylesheets/mixins.scss +16 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +73 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +20 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +17 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +51 -0
- package/package/frontend/toolkit/index.js +10 -0
- package/package/index.js +351 -0
- package/package/lib/deindex.js +18 -0
- package/package/lib/encryption.js +23 -0
- package/package/lib/ga-tag.js +89 -0
- package/package/lib/health.js +26 -0
- package/package/lib/helpers.js +66 -0
- package/package/lib/logger.js +65 -0
- package/package/lib/markdown.js +46 -0
- package/package/lib/router.js +111 -0
- package/package/lib/serve-static.js +12 -0
- package/package/lib/sessions.js +82 -0
- package/package/lib/settings.js +74 -0
- package/package/lib/which.js +28 -0
- package/package/middleware/cookies.js +43 -0
- package/package/middleware/deep-translate.js +32 -0
- package/package/middleware/errors.js +119 -0
- package/package/middleware/index.js +10 -0
- package/package/middleware/not-found.js +38 -0
- package/package/middleware/rate-limiter.js +98 -0
- package/package/middleware/service-unavailable.js +64 -0
- package/package/model/apis/axios-settings.js +21 -0
- package/package/model/apis/html-to-pdf-converter.js +35 -0
- package/package/model/apis/index.js +5 -0
- package/package/model/index.js +348 -0
- package/package/package.json +147 -0
- package/package/sandbox/README.md +66 -0
- package/package/sandbox/apps/sandbox/behaviours/clear-session.js +8 -0
- package/package/sandbox/apps/sandbox/behaviours/country-select.js +10 -0
- package/package/sandbox/apps/sandbox/behaviours/international-number.js +22 -0
- package/package/sandbox/apps/sandbox/fields.js +128 -0
- package/package/sandbox/apps/sandbox/index.js +99 -0
- package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +189 -0
- package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +43 -0
- package/package/sandbox/apps/sandbox/translations/src/en/errors.json +5 -0
- package/package/sandbox/apps/sandbox/translations/src/en/exit.json +4 -0
- package/package/sandbox/apps/sandbox/translations/src/en/fields.json +101 -0
- package/package/sandbox/apps/sandbox/translations/src/en/journey.json +7 -0
- package/package/sandbox/apps/sandbox/translations/src/en/pages.json +72 -0
- package/package/sandbox/apps/sandbox/translations/src/en/validation.json +54 -0
- package/package/sandbox/apps/sandbox/views/form-guidance-link.html +8 -0
- package/package/sandbox/apps/sandbox/views/save-and-exit.html +19 -0
- package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
- package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
- package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
- package/package/sandbox/assets/js/index.js +70 -0
- package/package/sandbox/assets/scss/app.scss +27 -0
- package/package/sandbox/codecept.conf.js +15 -0
- package/package/sandbox/config.js +17 -0
- package/package/sandbox/package.json +26 -0
- package/package/sandbox/server.js +23 -0
- package/package/sandbox/yarn.lock +262 -0
- package/package/transpiler/index.js +2 -0
- package/package/transpiler/lib/aggregate.js +32 -0
- package/package/transpiler/lib/build.js +15 -0
- package/package/transpiler/lib/compile.js +12 -0
- package/package/transpiler/lib/expand-dirs.js +14 -0
- package/package/transpiler/lib/write-files.js +24 -0
- package/package/utilities/autofill/index.js +189 -0
- package/package/utilities/autofill/inputs.js +60 -0
- package/package/utilities/countries.js +12 -0
- package/package/utilities/helpers/index.js +189 -0
- package/package/utilities/index.js +9 -0
- package/package/utilities/reqres/index.js +18 -0
- package/package/utilities/test-data/data/domain.json +7 -0
- package/package/utilities/test-data/data/firstname.json +16 -0
- package/package/utilities/test-data/data/lastname.json +10 -0
- package/package/utilities/test-data/data/postcode.json +12 -0
- package/package/utilities/test-data/data/streetname.json +8 -0
- package/package/utilities/test-data/data/streetsuffix.json +7 -0
- package/package/utilities/test-data/data/town.json +9 -0
- package/package/utilities/test-data/index.js +67 -0
- package/package/wizard/behaviours/complete.js +20 -0
- package/package/wizard/behaviours/index.js +5 -0
- package/package/wizard/index.js +124 -0
- package/package/wizard/middleware/back-links.js +68 -0
- package/package/wizard/middleware/check-complete.js +13 -0
- package/package/wizard/middleware/check-progress.js +139 -0
- package/package/wizard/middleware/check-session.js +17 -0
- package/package/wizard/middleware/csrf.js +47 -0
- package/package/wizard/middleware/session-model.js +11 -0
- package/package/wizard/middleware/session.js +9 -0
- package/package/wizard/model.js +29 -0
- package/package/wizard/util/constants.js +5 -0
- package/package/wizard/util/helpers.js +19 -0
- package/package.json +5 -6
- package/.editorconfig +0 -10
- package/.github/workflows/automate-publish.yml +0 -38
- package/.github/workflows/automate-tag.yml +0 -78
- package/.istanbul.yml +0 -20
- package/.nyc_output/be573ac3-d055-4910-a088-9d41b5345cec.json +0 -1
- package/.nyc_output/processinfo/be573ac3-d055-4910-a088-9d41b5345cec.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/codeReviewChecklist.md +0 -22
- package/pull_request_template.md +0 -16
@@ -0,0 +1,17 @@
|
|
1
|
+
.reveal {
|
2
|
+
float: left;
|
3
|
+
width: 100%;
|
4
|
+
.panel-indent {
|
5
|
+
margin-top: $gutter-half / 2;
|
6
|
+
margin-bottom: $gutter-half;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
fieldset + .reveal {
|
11
|
+
margin-top: -$gutter-half;
|
12
|
+
margin-bottom: $gutter-half;
|
13
|
+
@include media(tablet) {
|
14
|
+
margin-top: -$gutter;
|
15
|
+
margin-bottom: $gutter;
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
.validation-summary {
|
2
|
+
padding-left: $gutter-half - $validation-bdr-size-lg;
|
3
|
+
padding-right: $gutter-half;
|
4
|
+
border-width: $validation-bdr-size-lg;
|
5
|
+
|
6
|
+
&:focus {
|
7
|
+
outline: $focus-outline;
|
8
|
+
}
|
9
|
+
|
10
|
+
h2 {
|
11
|
+
margin: 0.3em 0;
|
12
|
+
}
|
13
|
+
ul {
|
14
|
+
margin: 0;
|
15
|
+
li {
|
16
|
+
margin: 0;
|
17
|
+
padding: 3px 0;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
a {
|
21
|
+
@include bold-19;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
.govuk-form-group--error {
|
26
|
+
box-sizing: border-box;
|
27
|
+
padding-left: $gutter-half - $validation-bdr-size;
|
28
|
+
border-left: $validation-bdr-size-lg solid $error-colour;
|
29
|
+
|
30
|
+
&:focus {
|
31
|
+
outline: $focus-outline;
|
32
|
+
}
|
33
|
+
|
34
|
+
.form-control {
|
35
|
+
margin-bottom: $validation-bdr-size;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
.govuk-error-message {
|
40
|
+
display: block;
|
41
|
+
@include media(tablet) {
|
42
|
+
margin-bottom: 0.5em;
|
43
|
+
}
|
44
|
+
@include bold-19;
|
45
|
+
color: $error-colour;
|
46
|
+
}
|
47
|
+
|
48
|
+
.invalid-input,
|
49
|
+
.govuk-form-group--error .date-input {
|
50
|
+
border: $validation-bdr-size solid $error-colour;
|
51
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module.exports = {
|
2
|
+
helpers: require('./assets/javascript/helpers'),
|
3
|
+
formFocus: require('./assets/javascript/form-focus'),
|
4
|
+
progressiveReveal: require('./assets/javascript/progressive-reveal'),
|
5
|
+
validation: require('./assets/javascript/validation'),
|
6
|
+
detailsSummary: function () {
|
7
|
+
require('./assets/javascript/vendor/details.polyfill');
|
8
|
+
},
|
9
|
+
characterCount: require('./assets/javascript/character-count')
|
10
|
+
};
|
package/package/index.js
ADDED
@@ -0,0 +1,351 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const crypto = require('crypto');
|
4
|
+
const express = require('express');
|
5
|
+
const morgan = require('morgan');
|
6
|
+
const path = require('path');
|
7
|
+
const http = require('http');
|
8
|
+
const https = require('https');
|
9
|
+
const mixins = require('./frontend').mixins;
|
10
|
+
const hofMiddleware = require('./middleware');
|
11
|
+
const markdown = require('./lib/markdown');
|
12
|
+
const translate = require('i18n-future').middleware;
|
13
|
+
const router = require('./lib/router');
|
14
|
+
const health = require('./lib/health');
|
15
|
+
const serveStatic = require('./lib/serve-static');
|
16
|
+
const gaTagSetup = require('./lib/ga-tag');
|
17
|
+
const deIndexer = require('./lib/deindex');
|
18
|
+
const sessionStore = require('./lib/sessions');
|
19
|
+
const settings = require('./lib/settings');
|
20
|
+
const defaults = require('./config/hof-defaults');
|
21
|
+
const logger = require('./lib/logger');
|
22
|
+
const helmet = require('helmet');
|
23
|
+
const _ = require('lodash');
|
24
|
+
const deprecate = require('deprecate');
|
25
|
+
|
26
|
+
const customConfig = {};
|
27
|
+
|
28
|
+
const getConfig = function () {
|
29
|
+
const args = [].slice.call(arguments);
|
30
|
+
const config = _.merge.apply(_, [{}, defaults, customConfig].concat(args));
|
31
|
+
|
32
|
+
if (!config.theme) {
|
33
|
+
config.theme = require('./frontend').themes.govUK;
|
34
|
+
} else if (typeof config.theme === 'string') {
|
35
|
+
config.theme = require('./frontend').themes[config.theme];
|
36
|
+
}
|
37
|
+
|
38
|
+
config.markdown = config.markdown || {};
|
39
|
+
|
40
|
+
return config;
|
41
|
+
};
|
42
|
+
|
43
|
+
const loadRoutes = (app, config) => {
|
44
|
+
config.routes.forEach(route => {
|
45
|
+
const routeConfig = Object.assign({}, config, {
|
46
|
+
route,
|
47
|
+
sharedViews: app.get('views')
|
48
|
+
});
|
49
|
+
app.use(route.baseUrl || '/', router(routeConfig));
|
50
|
+
});
|
51
|
+
};
|
52
|
+
|
53
|
+
const applyErrorMiddlewares = (app, config) => {
|
54
|
+
if (config.serviceUnavailable === true) {
|
55
|
+
app.use(hofMiddleware.serviceUnavailable({
|
56
|
+
logger: config.logger
|
57
|
+
}));
|
58
|
+
}
|
59
|
+
|
60
|
+
app.use(hofMiddleware.notFound({
|
61
|
+
logger: config.logger
|
62
|
+
}));
|
63
|
+
|
64
|
+
app.use(hofMiddleware.errors({
|
65
|
+
logger: config.logger,
|
66
|
+
debug: config.env === 'development'
|
67
|
+
}));
|
68
|
+
};
|
69
|
+
|
70
|
+
const getContentSecurityPolicy = (config, res) => {
|
71
|
+
const csp = config.csp;
|
72
|
+
|
73
|
+
/* eslint-disable quotes */
|
74
|
+
const directives = {
|
75
|
+
defaultSrc: ["'none'"],
|
76
|
+
styleSrc: ["'self'"],
|
77
|
+
imgSrc: ["'self'"],
|
78
|
+
fontSrc: ["'self'", 'data:', 'https://design-system.service.gov.uk'],
|
79
|
+
scriptSrc: ["'self'", `'nonce-${res.locals.nonce}'`],
|
80
|
+
'frame-ancestors': ["'none'"]
|
81
|
+
};
|
82
|
+
/* eslint-enable quotes */
|
83
|
+
|
84
|
+
const gaDirectives = {
|
85
|
+
styleSrc: ['www.googletagmanager.com', 'fonts.googleapis.com', 'tagmanager.google.com'],
|
86
|
+
fontSrc: ['fonts.gstatic.com '],
|
87
|
+
scriptSrc: ['www.google-analytics.com', 'ssl.google-analytics.com'],
|
88
|
+
imgSrc: [
|
89
|
+
'www.google-analytics.com',
|
90
|
+
'ssl.gstatic.com',
|
91
|
+
'www.google.co.uk/ads/ga-audiences'
|
92
|
+
],
|
93
|
+
connectSrc: [
|
94
|
+
"'self'",
|
95
|
+
'https://www.google-analytics.com',
|
96
|
+
'https://region1.google-analytics.com',
|
97
|
+
'https://region1.analytics.google.com'
|
98
|
+
]
|
99
|
+
};
|
100
|
+
|
101
|
+
if (config.gaTagId) {
|
102
|
+
directives.styleSrc = directives.styleSrc.concat(gaDirectives.styleSrc);
|
103
|
+
directives.scriptSrc = directives.scriptSrc.concat(gaDirectives.scriptSrc);
|
104
|
+
directives.fontSrc = directives.fontSrc.concat(gaDirectives.fontSrc);
|
105
|
+
directives.imgSrc = directives.imgSrc.concat(gaDirectives.imgSrc);
|
106
|
+
directives.connectSrc = gaDirectives.connectSrc;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (csp && !csp.disabled) {
|
110
|
+
_.each(csp, (value, name) => {
|
111
|
+
if (name === 'disabled') {
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
if (directives[name] && directives[name].length) {
|
115
|
+
// concat unique directives with existing directives
|
116
|
+
directives[name] = _.uniq(directives[name].concat(value));
|
117
|
+
} else {
|
118
|
+
directives[name] = _.isArray(value) ? value : [value];
|
119
|
+
}
|
120
|
+
});
|
121
|
+
}
|
122
|
+
return directives;
|
123
|
+
};
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Creates a new HOF application
|
127
|
+
*
|
128
|
+
* @param options {object} Configuration options for the HOF application
|
129
|
+
* @param options.behaviours {object | Array<object>} The HOF behaviour(s) to invoke for all sub-applications
|
130
|
+
* @param options.translations {string} The translations path for the application
|
131
|
+
* @param options.routes {Array<object>} The sub-applications for this app: for sandbox; require('./apps/sandbox')
|
132
|
+
* @param options.views {Array<string>} The view template paths for the application
|
133
|
+
* @param options.middleware {Array<function>} An array of Express middleware functions to use
|
134
|
+
* @param options.theme {string} Optional HOF theme - defaults to govuk
|
135
|
+
* @param options.markdown {object} Optional markdown options
|
136
|
+
* @param options.getTerms {boolean} Optional boolean - whether to mount the /terms endpoint
|
137
|
+
* @param options.getCookies {boolean} Optional boolean - whether to mount the /cookies endpoint
|
138
|
+
* @param options.noCache {boolean} Optional boolean - whether to disable caching
|
139
|
+
* @param options.getAccessibilityStatement {boolean} Optional boolean - whether to mount the
|
140
|
+
* /accessibility-statement endpoint
|
141
|
+
*
|
142
|
+
* @returns {object} A new HOF application using the configuration supplied in options
|
143
|
+
*/
|
144
|
+
function bootstrap(options) {
|
145
|
+
const config = getConfig(options);
|
146
|
+
|
147
|
+
const app = express();
|
148
|
+
const userMiddleware = express.Router();
|
149
|
+
|
150
|
+
app.use(helmet());
|
151
|
+
|
152
|
+
// Add common locals all pages can access
|
153
|
+
app.use((req, res, next) => {
|
154
|
+
res.locals.nonce = crypto.randomBytes(16).toString('hex');
|
155
|
+
res.locals.appName = config.appName;
|
156
|
+
res.locals.htmlLang = config.htmlLang;
|
157
|
+
res.locals.cookieName = config.session.name;
|
158
|
+
// session timeout warning configs
|
159
|
+
res.locals.sessionTimeOut = config.session.ttl;
|
160
|
+
res.locals.sessionTimeOutWarning = config.sessionTimeOutWarning;
|
161
|
+
res.locals.sessionTimeoutWarningContent = config.sessionTimeoutWarningContent;
|
162
|
+
res.locals.exitFormContent = config.exitFormContent;
|
163
|
+
res.locals.saveExitFormContent = config.saveExitFormContent;
|
164
|
+
res.locals.serviceUnavailable = config.serviceUnavailable;
|
165
|
+
res.locals.gaContainerId = config.ga4TagId;
|
166
|
+
next();
|
167
|
+
});
|
168
|
+
|
169
|
+
if (config.csp !== false && !config.csp.disabled) {
|
170
|
+
app.use((req, res, next) => {
|
171
|
+
helmet.contentSecurityPolicy({
|
172
|
+
directives: getContentSecurityPolicy(config, res)
|
173
|
+
})(req, res, next);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
|
177
|
+
app.use(helmet.noSniff());
|
178
|
+
|
179
|
+
if (config.noCache && config.noCache !== 'false') {
|
180
|
+
app.use((req, res, next) => {
|
181
|
+
res.setHeader('cache-control', ['no-store', 'no-cache', 'must-revalidate', 'proxy-revalidate']);
|
182
|
+
res.setHeader('pragma', 'no-cache');
|
183
|
+
next();
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
187
|
+
if (!config || !config.routes || !config.routes.length) {
|
188
|
+
throw new Error('Must be called with a list of routes');
|
189
|
+
}
|
190
|
+
|
191
|
+
config.routes.forEach(route => {
|
192
|
+
if (!route.steps && !route.pages) {
|
193
|
+
throw new Error('Each app must have steps and/or pages');
|
194
|
+
}
|
195
|
+
});
|
196
|
+
|
197
|
+
if (config.middleware) {
|
198
|
+
config.middleware.forEach(middleware => app.use(middleware));
|
199
|
+
}
|
200
|
+
|
201
|
+
config.logger = logger(config);
|
202
|
+
|
203
|
+
morgan.token('id', req => _.get(req, 'session.id', 'N/A'));
|
204
|
+
|
205
|
+
app.use(morgan('sessionId=:id ' + morgan.combined, {
|
206
|
+
stream: config.logger.stream,
|
207
|
+
skip: (req, res) => config.loglevel !== 'debug' &&
|
208
|
+
(
|
209
|
+
res.statusCode >= 300 || !_.get(req, 'session.id') ||
|
210
|
+
config.ignoreMiddlewareLogs.some(v => req.originalUrl.includes(v))
|
211
|
+
)
|
212
|
+
}));
|
213
|
+
|
214
|
+
serveStatic(app, config);
|
215
|
+
settings(app, config);
|
216
|
+
gaTagSetup(app, config);
|
217
|
+
deIndexer(app, config);
|
218
|
+
|
219
|
+
const sessions = sessionStore(app, config);
|
220
|
+
app.use('/healthz', health(sessions));
|
221
|
+
|
222
|
+
app.use((req, res, next) => {
|
223
|
+
const id = _.get(req, 'session.id', 'N/A');
|
224
|
+
req.log = config.logger.logSession(id);
|
225
|
+
next();
|
226
|
+
});
|
227
|
+
|
228
|
+
app.use(translate({
|
229
|
+
resources: config.theme.translations,
|
230
|
+
path: path.resolve(config.root, config.translations) + '/__lng__/__ns__.json'
|
231
|
+
}));
|
232
|
+
app.use(mixins());
|
233
|
+
app.use(markdown(config.markdown));
|
234
|
+
// rate limits have to be loaded before all routes so it is applied to them
|
235
|
+
if (config.rateLimits.requests.active) {
|
236
|
+
app.use(hofMiddleware.rateLimiter(config, 'requests'));
|
237
|
+
}
|
238
|
+
|
239
|
+
// Set up routing so <YOUR-SITE-URL>/assets are served from /node_modules/govuk-frontend/govuk/assets
|
240
|
+
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/assets')));
|
241
|
+
// Check if service has been paused and redirect accordingly
|
242
|
+
const bypassPaths = ['/assets', '/healthcheck', '/service-unavailable'];
|
243
|
+
|
244
|
+
if (config.serviceUnavailable === true) {
|
245
|
+
app.use((req, res, next) => {
|
246
|
+
if (!bypassPaths.some(bypassPath => req.path.startsWith(bypassPath))) {
|
247
|
+
return res.redirect('/service-unavailable');
|
248
|
+
}
|
249
|
+
return next();
|
250
|
+
});
|
251
|
+
}
|
252
|
+
if (config.getAccessibility === true) {
|
253
|
+
deprecate(
|
254
|
+
'`getAccessibility` option is deprecated and may be removed in future versions.',
|
255
|
+
'Use `pages` to define static cookies page.'
|
256
|
+
);
|
257
|
+
app.get('/accessibility', (req, res) => {
|
258
|
+
const locals = Object.assign({}, req.translate('accessibility'));
|
259
|
+
res.render('accessibility', locals);
|
260
|
+
});
|
261
|
+
}
|
262
|
+
if (config.getCookies === true) {
|
263
|
+
deprecate(
|
264
|
+
'`getCookies` option is deprecated and may be removed in future versions.',
|
265
|
+
'Use `pages` to define static cookies page.'
|
266
|
+
);
|
267
|
+
app.get('/cookies', (req, res) => {
|
268
|
+
const locals = Object.assign({}, req.translate('cookies'));
|
269
|
+
res.render('cookies', locals);
|
270
|
+
});
|
271
|
+
}
|
272
|
+
if (config.getTerms === true) {
|
273
|
+
deprecate(
|
274
|
+
'`getTerms` option is deprecated and may be removed in future versions.',
|
275
|
+
'Use `pages` to define static terms and conditions page.'
|
276
|
+
);
|
277
|
+
app.get('/terms-and-conditions', (req, res) => {
|
278
|
+
const locals = Object.assign({}, req.translate('terms'));
|
279
|
+
res.render('terms', locals);
|
280
|
+
});
|
281
|
+
}
|
282
|
+
|
283
|
+
app.use(userMiddleware);
|
284
|
+
app.use(hofMiddleware.cookies(config));
|
285
|
+
loadRoutes(app, config);
|
286
|
+
applyErrorMiddlewares(app, config);
|
287
|
+
|
288
|
+
const instance = {
|
289
|
+
use() {
|
290
|
+
userMiddleware.use.apply(userMiddleware, arguments);
|
291
|
+
return instance;
|
292
|
+
},
|
293
|
+
|
294
|
+
server: null,
|
295
|
+
|
296
|
+
start: sConfig => {
|
297
|
+
let startConfig = sConfig;
|
298
|
+
startConfig = getConfig(config, startConfig);
|
299
|
+
|
300
|
+
const protocol = startConfig.protocol === 'http' ? http : https;
|
301
|
+
|
302
|
+
instance.server = protocol.createServer(app);
|
303
|
+
|
304
|
+
return new Promise((resolve, reject) => {
|
305
|
+
instance.server.listen(startConfig.port, startConfig.host, err => {
|
306
|
+
if (err) {
|
307
|
+
reject(new Error('Unable to connect to server'));
|
308
|
+
}
|
309
|
+
config.logger.log('info', `${config.appName} started!`);
|
310
|
+
resolve(instance);
|
311
|
+
});
|
312
|
+
});
|
313
|
+
},
|
314
|
+
|
315
|
+
stop() {
|
316
|
+
return new Promise((resolve, reject) => instance.server.close(err => {
|
317
|
+
if (err) {
|
318
|
+
reject(new Error('Unable to stop server'));
|
319
|
+
}
|
320
|
+
config.logger.log('info', `${config.appName} stopped!`);
|
321
|
+
resolve(instance);
|
322
|
+
}));
|
323
|
+
}
|
324
|
+
};
|
325
|
+
|
326
|
+
if (config.start !== false) {
|
327
|
+
instance.start(config);
|
328
|
+
}
|
329
|
+
|
330
|
+
return instance;
|
331
|
+
}
|
332
|
+
|
333
|
+
bootstrap.configure = function (key, val) {
|
334
|
+
if (arguments.length === 2 && typeof key === 'string') {
|
335
|
+
customConfig[key] = val;
|
336
|
+
} else if (typeof key === 'object') {
|
337
|
+
Object.assign(customConfig, key);
|
338
|
+
}
|
339
|
+
};
|
340
|
+
|
341
|
+
module.exports = bootstrap;
|
342
|
+
module.exports.build = require('./build/');
|
343
|
+
module.exports.transpiler = require('./transpiler/');
|
344
|
+
module.exports.middleware = require('./middleware');
|
345
|
+
module.exports.controller = require('./controller');
|
346
|
+
module.exports.model = require('./model');
|
347
|
+
module.exports.apis = require('./model/apis');
|
348
|
+
module.exports.wizard = require('./wizard');
|
349
|
+
module.exports.components = require('./components');
|
350
|
+
module.exports.utils = require('./utilities');
|
351
|
+
module.exports.frontend = require('./frontend');
|
@@ -0,0 +1,18 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = (app, config) => {
|
4
|
+
// Ensure the value of deIndex is evaluated as a boolean regardless of if single quotes are used
|
5
|
+
// to have the expected conditional behaviour in the Mustache template
|
6
|
+
const deIndex = (config.deIndexForm === 'true' || config.deIndexForm === true);
|
7
|
+
|
8
|
+
app.use((req, res, next) => {
|
9
|
+
// Preparing common res.locals properties
|
10
|
+
const properties = {
|
11
|
+
deIndex: deIndex
|
12
|
+
};
|
13
|
+
res.locals = Object.assign(res.locals, properties);
|
14
|
+
next();
|
15
|
+
});
|
16
|
+
|
17
|
+
return app;
|
18
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const crypto = require('crypto');
|
5
|
+
const algorithm = 'aes-256-cbc';
|
6
|
+
|
7
|
+
module.exports = password => ({
|
8
|
+
|
9
|
+
encrypt: text => {
|
10
|
+
const cipher = crypto.createCipher(algorithm, password);
|
11
|
+
let crypted = cipher.update(text, 'utf8', 'hex');
|
12
|
+
crypted += cipher.final('hex');
|
13
|
+
return crypted;
|
14
|
+
},
|
15
|
+
|
16
|
+
decrypt: text => {
|
17
|
+
const decipher = crypto.createDecipher(algorithm, password);
|
18
|
+
let dec = decipher.update(text, 'hex', 'utf8');
|
19
|
+
dec += decipher.final('utf8');
|
20
|
+
return dec;
|
21
|
+
}
|
22
|
+
|
23
|
+
});
|
@@ -0,0 +1,89 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const _ = require('lodash');
|
4
|
+
|
5
|
+
const convertToGTMPage = text => {
|
6
|
+
// Remove leading and trailing slashes
|
7
|
+
let str = text.replace(/^\/|\/$/g, '');
|
8
|
+
// Replace hyphens with spaces and capitalize each word
|
9
|
+
str = str.replace(/-+/g, ' ').replace(/(^|\s)\S/g, function (match) {
|
10
|
+
return match.toUpperCase();
|
11
|
+
});
|
12
|
+
return str;
|
13
|
+
};
|
14
|
+
|
15
|
+
const pageView = (path, pageMap) => pageMap.get(path) || path;
|
16
|
+
|
17
|
+
const createUris = routes => {
|
18
|
+
const uris = _.map(routes, subApp => {
|
19
|
+
let subAppUris = Object.keys(subApp.steps || {});
|
20
|
+
const subAppBaseUrl = subApp.baseUrl;
|
21
|
+
|
22
|
+
if (subAppBaseUrl) {
|
23
|
+
subAppUris = _.map(subAppUris, uri => `${subAppBaseUrl}${uri}`);
|
24
|
+
subAppUris.unshift(subAppBaseUrl);
|
25
|
+
}
|
26
|
+
return subAppUris;
|
27
|
+
});
|
28
|
+
|
29
|
+
return _.flatten(uris);
|
30
|
+
};
|
31
|
+
|
32
|
+
const createIdentifiers = routes => _.map(routes, route => {
|
33
|
+
const routeIdentifier = route
|
34
|
+
.replace(/^[^A-Z0-9]+/gi, '')
|
35
|
+
.toLowerCase()
|
36
|
+
.replace(/([^A-Z0-9]+)(.)/ig, function () {
|
37
|
+
return arguments[2].toUpperCase();
|
38
|
+
});
|
39
|
+
|
40
|
+
return [route, routeIdentifier];
|
41
|
+
});
|
42
|
+
|
43
|
+
const setupPageMap = routes => {
|
44
|
+
let mappedRoutes = createUris(routes);
|
45
|
+
mappedRoutes = createIdentifiers(mappedRoutes);
|
46
|
+
|
47
|
+
const pageMap = new Map(mappedRoutes);
|
48
|
+
|
49
|
+
return pageMap;
|
50
|
+
};
|
51
|
+
|
52
|
+
module.exports = (app, config) => {
|
53
|
+
const gaTagId = config.gaTagId;
|
54
|
+
const ga4TagId = config.ga4TagId;
|
55
|
+
const gtm = config.gtm;
|
56
|
+
const gaCrossDomainTrackingTagId = config.gaCrossDomainTrackingTagId;
|
57
|
+
const routes = config.routes;
|
58
|
+
|
59
|
+
if (gaTagId || ga4TagId || gtm.tagId) {
|
60
|
+
const pageMap = setupPageMap(routes);
|
61
|
+
|
62
|
+
app.use((req, res, next) => {
|
63
|
+
const page = pageView(req.path, pageMap);
|
64
|
+
|
65
|
+
// Preparing common res.locals properties
|
66
|
+
const properties = {
|
67
|
+
gaAllowDebug: config.env === 'development',
|
68
|
+
gaTagId: gaTagId,
|
69
|
+
ga4TagId: ga4TagId,
|
70
|
+
gaCrossDomainTrackingTagId: gaCrossDomainTrackingTagId,
|
71
|
+
'ga-id': gaTagId,
|
72
|
+
'ga-page': page
|
73
|
+
};
|
74
|
+
|
75
|
+
// Adding extra properties if a GTM TAG is available
|
76
|
+
if (gtm.tagId) {
|
77
|
+
gtm.config.pageName = gtm.composePageName(page, convertToGTMPage);
|
78
|
+
Object.assign(properties, {
|
79
|
+
gtmConfig: JSON.stringify(gtm.config),
|
80
|
+
gtmTagId: gtm.tagId
|
81
|
+
});
|
82
|
+
}
|
83
|
+
res.locals = Object.assign(res.locals, properties);
|
84
|
+
next();
|
85
|
+
});
|
86
|
+
}
|
87
|
+
|
88
|
+
return app;
|
89
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
* This file provides readiness and liveness checks for use with Kubernetes.
|
3
|
+
* For information on how to set them up, look at the Kubernetes documentation:
|
4
|
+
*
|
5
|
+
* https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
const router = require('express').Router();
|
11
|
+
const healthCheck = require('express-healthcheck');
|
12
|
+
|
13
|
+
module.exports = redis => {
|
14
|
+
router.get('/ping', healthCheck());
|
15
|
+
|
16
|
+
router.get('/readiness', healthCheck({
|
17
|
+
test: () => {
|
18
|
+
if (!redis.connected && !redis.ready) {
|
19
|
+
return new Error('Session store unhealthy');
|
20
|
+
}
|
21
|
+
return 0;
|
22
|
+
}
|
23
|
+
}));
|
24
|
+
|
25
|
+
return router;
|
26
|
+
};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const fs = require('fs');
|
4
|
+
const path = require('path');
|
5
|
+
|
6
|
+
const getPath = (config, part) => {
|
7
|
+
let result = config.route[part] && path.resolve(config.root, config.route[part]);
|
8
|
+
if (!result) {
|
9
|
+
result = config.route.name && path.resolve(config.root, `apps/${config.route.name}/${part}`);
|
10
|
+
}
|
11
|
+
return result;
|
12
|
+
};
|
13
|
+
|
14
|
+
module.exports = class Helpers {
|
15
|
+
static getPaths(config) {
|
16
|
+
return {
|
17
|
+
fields: {
|
18
|
+
base: config.fields && path.resolve(config.root, config.fields),
|
19
|
+
route: getPath(config, 'fields')
|
20
|
+
},
|
21
|
+
views: getPath(config, 'views'),
|
22
|
+
translations: getPath(config, 'translations')
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
static getViews(views, strict) {
|
27
|
+
if (views) {
|
28
|
+
try {
|
29
|
+
fs.accessSync(views);
|
30
|
+
} catch (err) {
|
31
|
+
if (strict) {
|
32
|
+
throw new Error(`Cannot find route views at ${views}`);
|
33
|
+
} else {
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return views;
|
39
|
+
}
|
40
|
+
|
41
|
+
static getFields(pathFields) {
|
42
|
+
let routeFields;
|
43
|
+
let fields;
|
44
|
+
|
45
|
+
if (pathFields.base) {
|
46
|
+
try {
|
47
|
+
fields = require(pathFields.base);
|
48
|
+
} catch (err) {
|
49
|
+
throw new Error(`Cannot find fields at ${pathFields.base}`);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if (pathFields.route) {
|
53
|
+
try {
|
54
|
+
routeFields = require(pathFields.route);
|
55
|
+
} catch (err) {
|
56
|
+
throw new Error(`Cannot find route fields at ${pathFields.route}`);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
if (!fields && !routeFields) {
|
61
|
+
throw new Error('Set base fields or route fields or both');
|
62
|
+
}
|
63
|
+
|
64
|
+
return Object.assign({}, fields, routeFields);
|
65
|
+
}
|
66
|
+
};
|