Skip to content

Commit

Permalink
fix: allow fallback to fastify route config (#410)
Browse files Browse the repository at this point in the history
* fix: allow fallback to fastify@2.22 route config

* Apply suggestions from code review

Co-authored-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>

---------

Co-authored-by: Uzlopak <aras.abbasi@googlemail.com>
Co-authored-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
  • Loading branch information
3 people authored Sep 17, 2023
1 parent 2471a4c commit 8d0c3be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?.config || req.routeConfig
pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath)
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8d0c3be

Please sign in to comment.