Skip to content

Commit

Permalink
fix: request route config deprecation - fixes fastify#229
Browse files Browse the repository at this point in the history
  • Loading branch information
pgbross committed Sep 12, 2023
1 parent cf8b6cd commit a480494
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/global.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a480494

Please sign in to comment.