diff --git a/.env.example b/.env.example deleted file mode 100644 index f0508e1..0000000 --- a/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -REDIS_ENABLED=false -TOKEN_VERIFICATION_ENABLED=false - -# Credentials for allowing user access -AUTH_CODE_CLIENT_ID=hmpps-typescript-template -AUTH_CODE_CLIENT_SECRET=clientsecret - -# Credentials for API calls -CLIENT_CREDS_CLIENT_ID=hmpps-typescript-template-system -CLIENT_CREDS_CLIENT_SECRET=clientsecret diff --git a/integration_tests/pages/index.ts b/integration_tests/pages/index.ts index 4de3d1c..9da0fd5 100644 --- a/integration_tests/pages/index.ts +++ b/integration_tests/pages/index.ts @@ -2,7 +2,7 @@ import Page, { PageElement } from './page' export default class IndexPage extends Page { constructor() { - super('This site is under construction...') + super('Applications') } headerUserName = (): PageElement => cy.get('[data-qa=header-user-name]') diff --git a/server/routes/applications/index.ts b/server/routes/applications/index.ts new file mode 100644 index 0000000..4801259 --- /dev/null +++ b/server/routes/applications/index.ts @@ -0,0 +1,21 @@ +import { Request, Response, Router } from 'express' +import asyncMiddleware from '../../middleware/asyncMiddleware' +import AuditService, { Page } from '../../services/auditService' + +export default function applicationsRoutes({ auditService }: { auditService: AuditService }): Router { + const router = Router() + + router.get( + '/', + asyncMiddleware(async (req: Request, res: Response) => { + await auditService.logPageView(Page.APPLICATIONS_PAGE, { + who: res.locals.user.username, + correlationId: req.id, + }) + + res.render('pages/applications', { title: 'Applications' }) + }), + ) + + return router +} diff --git a/server/routes/index.test.ts b/server/routes/index.test.ts index d8cb5a8..08862a3 100644 --- a/server/routes/index.test.ts +++ b/server/routes/index.test.ts @@ -30,8 +30,7 @@ describe('GET /', () => { .get('/') .expect('Content-Type', /html/) .expect(res => { - expect(res.text).toContain('This site is under construction...') - expect(auditService.logPageView).toHaveBeenCalledWith(Page.EXAMPLE_PAGE, { + expect(auditService.logPageView).toHaveBeenCalledWith(Page.APPLICATIONS_PAGE, { who: user.username, correlationId: expect.any(String), }) diff --git a/server/routes/index.ts b/server/routes/index.ts index 2fa71df..61367a4 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,18 +1,13 @@ -import { type RequestHandler, Router } from 'express' +import { Router } from 'express' -import asyncMiddleware from '../middleware/asyncMiddleware' import type { Services } from '../services' -import { Page } from '../services/auditService' + +import applicationsRoutes from './applications' export default function routes({ auditService }: Services): Router { const router = Router() - const get = (path: string | string[], handler: RequestHandler) => router.get(path, asyncMiddleware(handler)) - - get('/', async (req, res, next) => { - await auditService.logPageView(Page.EXAMPLE_PAGE, { who: res.locals.user.username, correlationId: req.id }) - res.render('pages/index') - }) + router.use('/', applicationsRoutes({ auditService })) return router } diff --git a/server/services/auditService.ts b/server/services/auditService.ts index cabc199..004db12 100644 --- a/server/services/auditService.ts +++ b/server/services/auditService.ts @@ -2,6 +2,7 @@ import HmppsAuditClient, { AuditEvent } from '../data/hmppsAuditClient' export enum Page { EXAMPLE_PAGE = 'EXAMPLE_PAGE', + APPLICATIONS_PAGE = 'APPLICATIONS_PAGE', } export interface PageViewEventDetails { diff --git a/server/views/pages/applications.njk b/server/views/pages/applications.njk new file mode 100644 index 0000000..c768432 --- /dev/null +++ b/server/views/pages/applications.njk @@ -0,0 +1,10 @@ +{% extends "../partials/layout.njk" %} + +{% set pageTitle = applicationName + " - Applications" %} +{% set mainClasses = "app-container govuk-body" %} + +{% block content %} + +

{{ title }}

+ +{% endblock %}