From 631d6428fd21d0162685a3dc85a2078a5537553d Mon Sep 17 00:00:00 2001 From: Simon Boyd Date: Tue, 22 Oct 2024 08:47:45 +0100 Subject: [PATCH] Add healthcheck endpoint - fix h2 tag mismatch in start.njk - revert govuk-frontent to 4.8.0 --- package-lock.json | 8 ++++---- package.json | 4 ++-- src/constants.ts | 2 ++ src/routerDispatch.ts | 3 ++- src/routers/healthCheckRouter.ts | 13 ++++++++++++ src/routers/utils/index.ts | 3 ++- src/views/router_views/start/start.njk | 10 ++++----- terraform/groups/ecs-service/locals.tf | 8 ++++---- test/routers/healthCheck.int.ts | 28 ++++++++++++++++++++++++++ 9 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 src/routers/healthCheckRouter.ts create mode 100644 test/routers/healthCheck.int.ts diff --git a/package-lock.json b/package-lock.json index e6a56ccb..fa62ebe2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "express": "^4.21.1", "govuk_frontend_toolkit": "^9.0.1", "govuk-elements-sass": "^3.1.3", - "govuk-frontend": "^4.9.0", + "govuk-frontend": "^4.8.0", "http-errors": "^1.8.1", "ioredis": "4.28.5", "js-yaml": "^3.14.1", @@ -6271,9 +6271,9 @@ "integrity": "sha512-BlJsYnC0HJomBNCiBm2oQCqgbvP7vaA06XyJ2NocpWM4vFcK/AxAC/7gAU6iCjP3LVhyobR+o2MTFFGozPIE6A==" }, "node_modules/govuk-frontend": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.9.0.tgz", - "integrity": "sha512-zfX+GBUKpWBeV6JwCIawEuI8VRWlskH8Ok8aNUjKOvzo3zIaNbcrv4IOwgy+oSnMoGh67Eeh+vb7+9GFxN2fNg==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.8.0.tgz", + "integrity": "sha512-NOmPJxL8IYq1HSNHYKx9XY2LLTxuwb+IFASiGQO4sgJ8K7AG66SlSeqARrcetevV8zOf+i1z+MbJJ2O7//OxAw==", "license": "MIT", "engines": { "node": ">= 4.2.0" diff --git a/package.json b/package.json index 1d726ae2..83736fe3 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "express": "^4.21.1", "govuk_frontend_toolkit": "^9.0.1", "govuk-elements-sass": "^3.1.3", - "govuk-frontend": "^4.9.0", + "govuk-frontend": "^4.8.0", "http-errors": "^1.8.1", "ioredis": "4.28.5", "js-yaml": "^3.14.1", @@ -104,7 +104,7 @@ "overrides": { "chokidar": "3.5.3", "glob-parent": "6.0.2", - "micromatch":"4.0.8" + "micromatch": "4.0.8" }, "nodemonConfig": { "watch": [ diff --git a/src/constants.ts b/src/constants.ts index 92a853b7..874c0f72 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,6 +3,7 @@ const urlWithTransactionIdAndSubmissionId = "/transaction/:transactionId/submiss export const Urls = { ACCESSIBILITY_STATEMENT: "/persons-with-significant-control-verification", + HEALTHCHECK: "/healthcheck", START: "/start", COMPANY_NUMBER: "/company-number", CONFIRM_COMPANY: "/confirm-company", @@ -23,6 +24,7 @@ export const Urls = { export const PrefixedUrls = { ACCESSIBILITY_STATEMENT: servicePathPrefix + Urls.ACCESSIBILITY_STATEMENT, START: servicePathPrefix + Urls.START, + HEALTHCHECK: servicePathPrefix + Urls.HEALTHCHECK, COMPANY_NUMBER: servicePathPrefix + Urls.COMPANY_NUMBER, CONFIRM_COMPANY: servicePathPrefix + Urls.CONFIRM_COMPANY, NEW_SUBMISSION: servicePathPrefix + Urls.NEW_SUBMISSION, diff --git a/src/routerDispatch.ts b/src/routerDispatch.ts index 4cad305e..455b5f9a 100644 --- a/src/routerDispatch.ts +++ b/src/routerDispatch.ts @@ -1,7 +1,7 @@ // Do Router dispatch here, i.e. map incoming routes to appropriate router import { Application, Request, Response, Router } from "express"; import { Urls, servicePathPrefix } from "./constants"; -import { CompanyNumberRouter, ConfirmCompanyRouter, ConfirmRoStatementsRouter, IndividualPscListRouter, IndividualStatementRouter, NewSubmissionRouter, NotADirectorRouter, PersonalCodeRouter, PscTypeRouter, PscVerifiedRouter, RleDetailsRouter, RleDirectorRouter, RlePscListRouter, RleVerifiedRouter, StartRouter } from "./routers/utils"; +import { CompanyNumberRouter, ConfirmCompanyRouter, ConfirmRoStatementsRouter, HealthCheckRouter, IndividualPscListRouter, IndividualStatementRouter, NewSubmissionRouter, NotADirectorRouter, PersonalCodeRouter, PscTypeRouter, PscVerifiedRouter, RleDetailsRouter, RleDirectorRouter, RlePscListRouter, RleVerifiedRouter, StartRouter } from "./routers/utils"; import { authenticate } from "./middleware/authentication"; import { fetchVerification } from "./middleware/fetchVerification"; import { fetchCompany } from "./middleware/fetchCompany"; @@ -14,6 +14,7 @@ const routerDispatch = (app: Application) => { router.use("/", StartRouter); router.use(Urls.START, StartRouter); + router.use(Urls.HEALTHCHECK, HealthCheckRouter); router.use(Urls.COMPANY_NUMBER, authenticate, CompanyNumberRouter); router.use(Urls.CONFIRM_COMPANY, authenticate, ConfirmCompanyRouter); router.use(Urls.NEW_SUBMISSION, authenticate, NewSubmissionRouter); diff --git a/src/routers/healthCheckRouter.ts b/src/routers/healthCheckRouter.ts new file mode 100644 index 00000000..20e6c100 --- /dev/null +++ b/src/routers/healthCheckRouter.ts @@ -0,0 +1,13 @@ +import { HttpStatusCode } from "axios"; +import { Request, Response, Router } from "express"; +import { logger } from "../lib/logger"; + +const healthCheckRouter: Router = Router(); + +healthCheckRouter.get("/", (req: Request, res: Response) => { + logger.debugRequest(req, `GET healthcheck`); + + res.status(HttpStatusCode.Ok).send("OK"); +}); + +export default healthCheckRouter; diff --git a/src/routers/utils/index.ts b/src/routers/utils/index.ts index 4d81d57f..1f25d496 100644 --- a/src/routers/utils/index.ts +++ b/src/routers/utils/index.ts @@ -1,4 +1,5 @@ import StartRouter from "./../startRouter"; +import HealthCheckRouter from "./../healthCheckRouter"; import CompanyNumberRouter from "./../companyNumberRouter"; import ConfirmCompanyRouter from "./../confirmCompanyRouter"; import NewSubmissionRouter from "./../newSubmissionRouter"; @@ -14,7 +15,7 @@ import ConfirmRoStatementsRouter from "./../confirmRoStatementsRouter"; import NotADirectorRouter from "./../notADirectorRouter"; import RleVerifiedRouter from "./../rleVerifiedRouter"; import { logger } from "../../lib/logger"; -export { StartRouter, CompanyNumberRouter, ConfirmCompanyRouter, PscTypeRouter, IndividualPscListRouter, PersonalCodeRouter, IndividualStatementRouter, NewSubmissionRouter, NotADirectorRouter, PscVerifiedRouter, RlePscListRouter, RleDetailsRouter, RleDirectorRouter, RleVerifiedRouter, ConfirmRoStatementsRouter }; +export { StartRouter, HealthCheckRouter, CompanyNumberRouter, ConfirmCompanyRouter, PscTypeRouter, IndividualPscListRouter, PersonalCodeRouter, IndividualStatementRouter, NewSubmissionRouter, NotADirectorRouter, PscVerifiedRouter, RlePscListRouter, RleDetailsRouter, RleDirectorRouter, RleVerifiedRouter, ConfirmRoStatementsRouter }; export function formatDateBorn (dateOfBirth: any, lang: string): string { try { diff --git a/src/views/router_views/start/start.njk b/src/views/router_views/start/start.njk index 3890aedb..213868e6 100644 --- a/src/views/router_views/start/start.njk +++ b/src/views/router_views/start/start.njk @@ -11,14 +11,14 @@

{{ i18n.start_main_title }}

{{ i18n.start_service_description }}

- + {{ govukInsetText({ text: i18n.start_inset_text }) }}

{{ i18n.start_service_restriction_description }}

- -

{{ i18n.start_when_to_verify_heading }}

+ +

{{ i18n.start_when_to_verify_heading }}

{{ i18n.start_when_to_verify_description1 }}

{{ i18n.start_when_to_verify_description2 }}

{{ i18n.start_when_to_verify_description3 }}

@@ -39,7 +39,7 @@

{{i18n.start_before_list}}

- +