fastify-static
Advanced tools
Comparing version 3.2.1 to 3.3.0
24
index.js
@@ -130,4 +130,16 @@ 'use strict' | ||
const errorHandler = (error, request, reply) => { | ||
if (error && error.code === 'ERR_STREAM_PREMATURE_CLOSE') { | ||
reply.request.raw.destroy() | ||
return | ||
} | ||
fastify.errorHandler(error, request, reply) | ||
} | ||
// Set the schema hide property if defined in opts or true by default | ||
const schema = { schema: { hide: typeof opts.schemaHide !== 'undefined' ? opts.schemaHide : true } } | ||
const routeOpts = { | ||
schema: { hide: typeof opts.schemaHide !== 'undefined' ? opts.schemaHide : true }, | ||
errorHandler: fastify.errorHandler ? errorHandler : undefined | ||
} | ||
@@ -143,7 +155,7 @@ if (opts.decorateReply !== false) { | ||
if (opts.wildcard === undefined || opts.wildcard === true) { | ||
fastify.get(prefix + '*', schema, function (req, reply) { | ||
fastify.get(prefix + '*', routeOpts, function (req, reply) { | ||
pumpSendToReply(req, reply, '/' + req.params['*']) | ||
}) | ||
if (opts.redirect === true && prefix !== opts.prefix) { | ||
fastify.get(opts.prefix, schema, function (req, reply) { | ||
fastify.get(opts.prefix, routeOpts, function (req, reply) { | ||
/* eslint node/no-deprecated-api: "off" */ | ||
@@ -165,3 +177,3 @@ const parsed = url.parse(req.raw.url) | ||
const route = (prefix + file).replace(/\/\//g, '/') | ||
fastify.get(route, schema, function (req, reply) { | ||
fastify.get(route, routeOpts, function (req, reply) { | ||
pumpSendToReply(req, reply, '/' + file) | ||
@@ -178,3 +190,3 @@ }) | ||
fastify.get(pathname, schema, function (req, reply) { | ||
fastify.get(pathname, routeOpts, function (req, reply) { | ||
pumpSendToReply(req, reply, file) | ||
@@ -184,3 +196,3 @@ }) | ||
if (opts.redirect === true) { | ||
fastify.get(pathname.replace(/\/$/, ''), schema, function (req, reply) { | ||
fastify.get(pathname.replace(/\/$/, ''), routeOpts, function (req, reply) { | ||
pumpSendToReply(req, reply, file.replace(/\/$/, '')) | ||
@@ -187,0 +199,0 @@ }) |
{ | ||
"name": "fastify-static", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Plugin for serving static files as fast as possible.", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"fastify-plugin": "^2.3.4", | ||
"fastify-plugin": "^3.0.0", | ||
"glob": "^7.1.4", | ||
@@ -44,3 +44,3 @@ "readable-stream": "^3.4.0", | ||
"eslint-plugin-typescript": "^0.14.0", | ||
"fastify": "^3.0.0", | ||
"fastify": "^3.7.0", | ||
"fastify-compress": "^3.3.1", | ||
@@ -47,0 +47,0 @@ "handlebars": "^4.7.6", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199980
2787
+ Addedfastify-plugin@3.0.1(transitive)
- Removedfastify-plugin@2.3.4(transitive)
- Removedsemver@7.6.3(transitive)
Updatedfastify-plugin@^3.0.0