From 4209c935d638055c31a4653925bdd382c1025cbb Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 1 Oct 2022 18:01:32 +0800 Subject: [PATCH] Replace deprecated context.config with routeConfig --- index.js | 4 ++-- test/global.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9e11b01..79ffc5a 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,7 @@ async function helmetPlugin (fastify, options) { }) fastify.addHook('onRequest', async (request, reply) => { - const { helmet: routeOptions } = request.context.config + const { helmet: routeOptions } = request.routeConfig if (typeof routeOptions !== 'undefined') { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions @@ -50,7 +50,7 @@ async function helmetPlugin (fastify, options) { }) fastify.addHook('onRequest', (request, reply, next) => { - const { helmet: routeOptions } = request.context.config + const { helmet: routeOptions } = request.routeConfig if (typeof routeOptions !== 'undefined') { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions diff --git a/test/global.test.js b/test/global.test.js index b0864de..38e9878 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.context.config.fail + const crash = request.routeConfig.fail Promise.resolve(crash).then((fail) => { if (fail === true) {