@fastify/static
Advanced tools
Comparing version 6.4.1 to 6.5.0
@@ -5,3 +5,3 @@ // Definitions by: Jannik <https://github.com/jannikkeye> | ||
import { FastifyPluginCallback, FastifyReply } from 'fastify'; | ||
import { FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify'; | ||
import { Stats } from 'fs'; | ||
@@ -90,3 +90,3 @@ | ||
list?: boolean | ListOptionsJsonFormat | ListOptionsHtmlFormat; | ||
allowedPath?: (pathName: string, root?: string) => boolean; | ||
allowedPath?: (pathName: string, root: string, request: FastifyRequest) => boolean; | ||
/** | ||
@@ -93,0 +93,0 @@ * @description |
@@ -75,3 +75,3 @@ 'use strict' | ||
if (allowedPath && !allowedPath(pathname, options.root)) { | ||
if (allowedPath && !allowedPath(pathname, options.root, request)) { | ||
return reply.callNotFound() | ||
@@ -78,0 +78,0 @@ } |
{ | ||
"name": "@fastify/static", | ||
"version": "6.4.1", | ||
"version": "6.5.0", | ||
"description": "Plugin for serving static files as fast as possible.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,3 +14,3 @@ # @fastify/static | ||
`npm install --save @fastify/static` | ||
`npm i @fastify/static` | ||
@@ -173,5 +173,5 @@ ## Usage | ||
Default: `(pathname, root) => true` | ||
Default: `(pathName, root, request) => true` | ||
This function allows filtering the served files. | ||
This function allows filtering the served files. Also, with the help of the request object a more complex path authentication is possible. | ||
If the function returns `true`, the file will be served. | ||
@@ -178,0 +178,0 @@ If the function returns `false`, Fastify's 404 handler will be called. |
@@ -1,2 +0,2 @@ | ||
import fastify, { FastifyInstance, FastifyPluginCallback } from 'fastify' | ||
import fastify, { FastifyInstance, FastifyPluginCallback, FastifyRequest } from 'fastify' | ||
import { Server } from 'http'; | ||
@@ -55,3 +55,6 @@ import { expectAssignable, expectError, expectType } from 'tsd' | ||
}, | ||
preCompressed: false | ||
preCompressed: false, | ||
allowedPath: (pathName: string, root: string, request: FastifyRequest) => { | ||
return true; | ||
} | ||
} | ||
@@ -58,0 +61,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
365382
52
4791
6