Skip to content

Switch to nhsuk-prototype-kit package#178

Open
frankieroberto wants to merge 20 commits intomainfrom
use-nhsuk-prototype-kit-package
Open

Switch to nhsuk-prototype-kit package#178
frankieroberto wants to merge 20 commits intomainfrom
use-nhsuk-prototype-kit-package

Conversation

@frankieroberto
Copy link

A spike to see if/how the nhsuk-prototype-rig could be swapped out for the (not yet released) nhsuk-prototype-kit package.

Part of nhsuk/nhsuk-prototype-kit-package#49

@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--hezvbz November 30, 2025 21:04 Inactive
@paulrobertlloyd
Copy link
Collaborator

@frankieroberto Oooh, I was thinking of trying this, glad you’ve taken up the challenge! How does it fair?

@frankieroberto
Copy link
Author

@paulrobertlloyd well it’s not working yet. Need to take some time to go through all the errors one by one.

I’d like to switch the package from CommonJS to ESM modules but probably it needs to work with both for a while?!

One other issue is that your prototype uses .njk instead of .html so the auto routes don’t work. Probably it should work with both options!

@paulrobertlloyd
Copy link
Collaborator

@frankieroberto Give up!?

@frankieroberto
Copy link
Author

@paulrobertlloyd no just ran out of time that night! Will pick this up again soon. Might end up being a Christmas break project.

Feel free to push any commits if you spot anything.

@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--gx3vf7 December 12, 2025 22:47 Inactive
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--vsbfek December 12, 2025 23:08 Inactive
@frankieroberto frankieroberto had a problem deploying to mavis-protot-use-nhsuk--yg77si December 12, 2025 23:10 Failure
@frankieroberto
Copy link
Author

@paulrobertlloyd ok, 1 step closer to working. I’ve updated the kit (8.0.0-internal.5) to support ES modules. The prototype will now start, and the CSS files are built.

However all the pages throw an error - which I think is because the prototype is now missing all Postgres database stuff. Looks like the connect-pg-simple package would need to be added to the prototype along with this code? https://github.com/x-govuk/nhsuk-prototype-rig/blob/main/lib/server.js#L124-L143

One for another day!

@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--185lgl December 16, 2025 13:37 Inactive
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo December 16, 2025 20:37 Inactive
@colinrotherham colinrotherham temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 3, 2026 09:21 Inactive
@colinrotherham
Copy link
Contributor

@paulrobertlloyd Need you to add a PASSWORD env to the review app 🙏

We should ideally add a globals option (alongside filters) and I've had to temporarily turn off the PostgreSQL session middleware for now, but the v8 prototype kit version is up and running 😎

@frankieroberto
Copy link
Author

@colinrotherham there was already a PASSWORD env set up, but the kit requires a PROTOTYPE_PASSWORD one (not sure why but it always has). I've added it now (password: mavis). Seems to work!

@paulrobertlloyd give it a test?

@frankieroberto frankieroberto marked this pull request as ready for review February 3, 2026 20:23
@frankieroberto frankieroberto changed the title WIP SPIKE: Test switching to nhsuk-prototype-kit package Switch to nhsuk-prototype-kit package Feb 3, 2026
@paulrobertlloyd paulrobertlloyd force-pushed the use-nhsuk-prototype-kit-package branch from c1b7288 to e20ae6a Compare February 20, 2026 21:27
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 21:28 Inactive
@paulrobertlloyd paulrobertlloyd force-pushed the use-nhsuk-prototype-kit-package branch from e20ae6a to ed2a6b3 Compare February 20, 2026 21:29
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 21:30 Inactive
@paulrobertlloyd paulrobertlloyd force-pushed the use-nhsuk-prototype-kit-package branch from ed2a6b3 to c7ee0da Compare February 20, 2026 21:32
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 21:32 Inactive
@paulrobertlloyd paulrobertlloyd force-pushed the use-nhsuk-prototype-kit-package branch from c7ee0da to 69a8a0c Compare February 20, 2026 21:43
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 21:44 Inactive
@frankieroberto frankieroberto temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 22:11 Inactive
@paulrobertlloyd paulrobertlloyd force-pushed the use-nhsuk-prototype-kit-package branch from 3bbf5fa to 4215a0f Compare February 20, 2026 22:21
@paulrobertlloyd paulrobertlloyd temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 22:21 Inactive
@frankieroberto frankieroberto temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 22:28 Inactive
@frankieroberto frankieroberto temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 22:55 Inactive
@frankieroberto frankieroberto temporarily deployed to mavis-protot-use-nhsuk--kdxzzo February 20, 2026 23:06 Inactive
@paulrobertlloyd
Copy link
Collaborator

This is mostly working now, but one outstanding issue is request.body often returning an empty object ({}) when a form is submitted, which isn’t the case currently.

I thought adding the following would work:

app.use(express.json())
app.use(
  express.urlencoded({
    extended: true
  })
)

As this is used in the Rig. However this made no difference. This’ll need some more digging to resolve.

@frankieroberto
Copy link
Author

@paulrobertlloyd can you remember which pages/routes the request.body is being set to an empty object on?

sessionDataDefaults
})

prototype.app.set('view engine', 'njk')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break all the internal error views etc that use .html extensions?

Or basic things like password.html in Heroku?

I've proposed a fix in nhsuk/nhsuk-prototype-kit-package#260

But otherwise, could you add the extensions manually for now?

- response.render('dashboard')
+ response.render('dashboard.njk')

prototype.nunjucks?.addGlobal(key, value)
}

prototype.start(2000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this port for Browsersync now, not Express

So assuming you want to continue using http://localhost:3000

Suggested change
prototype.start(2000)
prototype.start(3000)


const prototype = await NHSPrototypeKit.init({
serviceName: 'Manage vaccinations in schools',
app,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This app will receive a second app.use(session) store 😔

I'm not quite sure how that might behave, unless it's somehow adding a different non-conflicting name to the request?

Similarly expect lots of async session weirdness:

  • We reset using req.session.data = {} not req.session.regenerate()
  • We don't wait for req.session.save() before redirecting after POST

Probably need to wait for (and help test) this new feature instead:

@paulrobertlloyd
Copy link
Collaborator

@paulrobertlloyd can you remember which pages/routes the request.body is being set to an empty object on?

Try logging in as a nurse, going to an in progress session, and registering a child. And if that works, recording a vaccination. That whole flow is broken right now.

colinrotherham added a commit to nhsuk/nhsuk-prototype-kit-package that referenced this pull request Feb 26, 2026
This PR adds support for an (optional) Express `session` option for
custom session stores

This change unblocks
NHSDigital/manage-vaccinations-in-schools-prototype#178
and uses:

* `req.session.regenerate()` during session reset
* `req.session.save()` after session reset

```mjs
const prototype = await NHSPrototypeKit.init({
  session: expressSession({
    secret: 'Shhh'
  })
})
```

We should test this feature with various asynchronous session stores
@paulrobertlloyd paulrobertlloyd force-pushed the main branch 2 times, most recently from f453b8d to f11a87a Compare March 9, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants