From 846c9841e0645bff249df9fcc306b7dc62f87bf4 Mon Sep 17 00:00:00 2001 From: KaKa Date: Sun, 17 Sep 2023 06:48:20 +0800 Subject: [PATCH 1/2] fix: allow fallback to fastify@2.22 route config --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ff7550c..86fbe8b 100644 --- a/index.js +++ b/index.js @@ -396,7 +396,9 @@ async function fastifyStatic (fastify, opts) { } function serveFileHandler (req, reply) { - const routeConfig = req.routeOptions.config + // TODO: remove the fallback branch when bump major + /* istanbul ignore next */ + const routeConfig = (req.routeOptions && req.routeConfig.config) || req.routeConfig pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath) } } @@ -552,7 +554,7 @@ function getRedirectUrl (url) { } module.exports = fp(fastifyStatic, { - fastify: '^4.23.0', + fastify: '4.x', name: '@fastify/static' }) module.exports.default = fastifyStatic From e3c8825d408a7c24c746ff53e4fac21cf18abdfb Mon Sep 17 00:00:00 2001 From: Uzlopak Date: Sun, 17 Sep 2023 01:51:39 +0200 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gürgün Dayıoğlu --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 86fbe8b..559b7e5 100644 --- a/index.js +++ b/index.js @@ -398,7 +398,7 @@ async function fastifyStatic (fastify, opts) { function serveFileHandler (req, reply) { // TODO: remove the fallback branch when bump major /* istanbul ignore next */ - const routeConfig = (req.routeOptions && req.routeConfig.config) || req.routeConfig + const routeConfig = req.routeOptions?.config || req.routeConfig pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath) } }