fastify-static
Advanced tools
Comparing version 4.2.4 to 4.3.0
@@ -10,2 +10,4 @@ // Definitions by: Jannik <https://github.com/jannikkeye> | ||
sendFile(filename: string, rootPath?: string): FastifyReply; | ||
sendFile(filename: string, options?: SendOptions): FastifyReply; | ||
sendFile(filename: string, rootPath?: string, options?: SendOptions): FastifyReply; | ||
download(filepath: string, options?: SendOptions): FastifyReply; | ||
@@ -12,0 +14,0 @@ download(filepath: string, filename?: string): FastifyReply; |
@@ -235,3 +235,5 @@ 'use strict' | ||
if (opts.decorateReply !== false) { | ||
fastify.decorateReply('sendFile', function (filePath, rootPath) { | ||
fastify.decorateReply('sendFile', function (filePath, rootPath, options) { | ||
const opts = typeof rootPath === 'object' ? rootPath : options | ||
const root = typeof rootPath === 'string' ? rootPath : opts && opts.root | ||
pumpSendToReply( | ||
@@ -241,3 +243,5 @@ this.request, | ||
filePath, | ||
rootPath || sendOptions.root | ||
root || sendOptions.root, | ||
0, | ||
opts | ||
) | ||
@@ -244,0 +248,0 @@ return this |
{ | ||
"name": "fastify-static", | ||
"version": "4.2.4", | ||
"version": "4.3.0", | ||
"description": "Plugin for serving static files as fast as possible.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,2 +36,5 @@ # fastify-static | ||
fastify.get('/another/path', function (req, reply) { | ||
return reply.sendFile('myHtml.html', { cacheControl: false }) // overriding the options disabling cache-control headers | ||
}) | ||
``` | ||
@@ -38,0 +41,0 @@ |
@@ -74,2 +74,10 @@ import fastify from 'fastify' | ||
multiRootAppWithImplicitHttp.get('/', (request, reply) => { | ||
reply.sendFile('some-file-name', { cacheControl: false, acceptRanges: true }) | ||
}) | ||
multiRootAppWithImplicitHttp.get('/', (request, reply) => { | ||
reply.sendFile('some-file-name', 'some-root-name', { cacheControl: false, acceptRanges: true }) | ||
}) | ||
multiRootAppWithImplicitHttp.get('/download', (request, reply) => { | ||
@@ -76,0 +84,0 @@ reply.download('some-file-name') |
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
337338
3978
358