From a4804940a55fe19401ce12d48b9b85fdf62c1ba2 Mon Sep 17 00:00:00 2001 From: philip ross Date: Tue, 12 Sep 2023 11:38:13 +0100 Subject: [PATCH] fix: request route config deprecation - fixes #229 --- index.js | 4 ++-- test/global.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b9db876..671db56 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ async function fastifyHelmet (fastify, options) { fastify.addHook('onRequest', async (request, reply) => { /* istanbul ignore next */ - const { helmet: routeOptions } = request.routeConfig || request.context.config + const { helmet: routeOptions } = request.routeOptions.config || request.context.config if (typeof routeOptions !== 'undefined') { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions @@ -52,7 +52,7 @@ async function fastifyHelmet (fastify, options) { fastify.addHook('onRequest', (request, reply, next) => { /* istanbul ignore next */ - const { helmet: routeOptions } = request.routeConfig || request.context.config + const { helmet: routeOptions } = request.routeOptions.config || request.context.config if (typeof routeOptions !== 'undefined') { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions diff --git a/test/global.test.js b/test/global.test.js index 901cd18..ce99417 100644 --- a/test/global.test.js +++ b/test/global.test.js @@ -685,7 +685,7 @@ test('It should not return a fastify `FST_ERR_REP_ALREADY_SENT - Reply already s } // We want to crash in the scope of this test - const crash = request.routeConfig.fail + const crash = request.routeOptions.config.fail Promise.resolve(crash).then((fail) => { if (fail === true) {