Socket
Socket
Sign inDemoInstall

@fastify/static

Package Overview
Dependencies
Maintainers
19
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/static - npm Package Compare versions

Comparing version 6.4.0 to 6.4.1

170

index.d.ts

@@ -11,98 +11,106 @@ // 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;
sendFile(filename: string, options?: fastifyStatic.SendOptions): FastifyReply;
sendFile(filename: string, rootPath?: string, options?: fastifyStatic.SendOptions): FastifyReply;
download(filepath: string, options?: fastifyStatic.SendOptions): FastifyReply;
download(filepath: string, filename?: string): FastifyReply;
download(filepath: string, filename?: string, options?: SendOptions): FastifyReply;
download(filepath: string, filename?: string, options?: fastifyStatic.SendOptions): FastifyReply;
}
}
interface ExtendedInformation {
fileCount: number;
totalFileCount: number;
folderCount: number;
totalFolderCount: number;
totalSize: number;
lastModified: number;
}
type FastifyStaticPlugin = FastifyPluginCallback<NonNullable<fastifyStatic.FastifyStaticOptions>>;
interface ListDir {
href: string;
name: string;
stats: Stats;
extendedInfo?: ExtendedInformation;
}
declare namespace fastifyStatic {
export interface ExtendedInformation {
fileCount: number;
totalFileCount: number;
folderCount: number;
totalFolderCount: number;
totalSize: number;
lastModified: number;
}
interface ListFile {
href: string;
name: string;
stats: Stats;
}
export interface ListDir {
href: string;
name: string;
stats: Stats;
extendedInfo?: ExtendedInformation;
}
interface ListRender {
(dirs: ListDir[], files: ListFile[]): string;
}
export interface ListFile {
href: string;
name: string;
stats: Stats;
}
interface ListOptions {
names?: string[];
extendedFolderInfo?: boolean;
jsonFormat?: 'names' | 'extended';
}
export interface ListRender {
(dirs: ListDir[], files: ListFile[]): string;
}
interface ListOptionsJsonFormat extends ListOptions {
format: 'json';
// Required when the URL parameter `format=html` exists
render?: ListRender;
}
export interface ListOptions {
names?: string[];
extendedFolderInfo?: boolean;
jsonFormat?: 'names' | 'extended';
}
interface ListOptionsHtmlFormat extends ListOptions {
format: 'html';
render: ListRender;
}
export interface ListOptionsJsonFormat extends ListOptions {
format: 'json';
// Required when the URL parameter `format=html` exists
render?: ListRender;
}
// Passed on to `send`
interface SendOptions {
acceptRanges?: boolean;
cacheControl?: boolean;
dotfiles?: 'allow' | 'deny' | 'ignore';
etag?: boolean;
extensions?: string[];
immutable?: boolean;
index?: string[] | string | false;
lastModified?: boolean;
maxAge?: string | number;
}
export interface ListOptionsHtmlFormat extends ListOptions {
format: 'html';
render: ListRender;
}
export interface FastifyStaticOptions extends SendOptions {
root: string | string[];
prefix?: string;
prefixAvoidTrailingSlash?: boolean;
serve?: boolean;
decorateReply?: boolean;
schemaHide?: boolean;
setHeaders?: (...args: any[]) => void;
redirect?: boolean;
wildcard?: boolean;
list?: boolean | ListOptionsJsonFormat | ListOptionsHtmlFormat;
allowedPath?: (pathName: string, root?: string) => boolean;
/**
* @description
* Opt-in to looking for pre-compressed files
*/
preCompressed?: boolean;
// Passed on to `send`
export interface SendOptions {
acceptRanges?: boolean;
cacheControl?: boolean;
dotfiles?: 'allow' | 'deny' | 'ignore';
etag?: boolean;
extensions?: string[];
immutable?: boolean;
index?: string[] | string | false;
lastModified?: boolean;
maxAge?: string | number;
}
// Passed on to `send`
acceptRanges?: boolean;
cacheControl?: boolean;
dotfiles?: 'allow' | 'deny' | 'ignore';
etag?: boolean;
extensions?: string[];
immutable?: boolean;
index?: string[] | string | false;
lastModified?: boolean;
maxAge?: string | number;
export interface FastifyStaticOptions extends SendOptions {
root: string | string[];
prefix?: string;
prefixAvoidTrailingSlash?: boolean;
serve?: boolean;
decorateReply?: boolean;
schemaHide?: boolean;
setHeaders?: (...args: any[]) => void;
redirect?: boolean;
wildcard?: boolean;
list?: boolean | ListOptionsJsonFormat | ListOptionsHtmlFormat;
allowedPath?: (pathName: string, root?: string) => boolean;
/**
* @description
* Opt-in to looking for pre-compressed files
*/
preCompressed?: boolean;
// Passed on to `send`
acceptRanges?: boolean;
cacheControl?: boolean;
dotfiles?: 'allow' | 'deny' | 'ignore';
etag?: boolean;
extensions?: string[];
immutable?: boolean;
index?: string[] | string | false;
lastModified?: boolean;
maxAge?: string | number;
}
export const fastifyStatic: FastifyStaticPlugin;
export { fastifyStatic as default };
}
export declare const fastifyStatic: FastifyPluginCallback<FastifyStaticOptions>
declare function fastifyStatic(...params: Parameters<FastifyStaticPlugin>): ReturnType<FastifyStaticPlugin>;
export default fastifyStatic;
export = fastifyStatic;

@@ -12,3 +12,3 @@ 'use strict'

const globPromise = util.promisify(glob)
const encodingNegotiator = require('encoding-negotiator')
const encodingNegotiator = require('@fastify/accept-negotiator')

@@ -15,0 +15,0 @@ const dirList = require('./lib/dirList')

{
"name": "@fastify/static",
"version": "6.4.0",
"version": "6.4.1",
"description": "Plugin for serving static files as fast as possible.",

@@ -33,7 +33,7 @@ "main": "index.js",

"content-disposition": "^0.5.3",
"encoding-negotiator": "^2.0.1",
"fastify-plugin": "^3.0.0",
"@fastify/accept-negotiator": "^1.0.0",
"fastify-plugin": "^4.0.0",
"glob": "^8.0.1",
"p-limit": "^3.1.0",
"readable-stream": "^3.4.0",
"readable-stream": "^4.0.0",
"send": "^0.18.0"

@@ -43,3 +43,3 @@ },

"@fastify/compress": "^6.0.0",
"@types/node": "^17.0.0",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",

@@ -58,3 +58,3 @@ "@typescript-eslint/parser": "^2.29.0",

"tap": "^16.0.0",
"tsd": "^0.20.0",
"tsd": "^0.22.0",
"typescript": "^4.0.2"

@@ -61,0 +61,0 @@ },

@@ -1,5 +0,33 @@

import fastify from 'fastify'
import { expectAssignable, expectError } from 'tsd'
import fastifyStatic, { FastifyStaticOptions } from '../..'
import fastify, { FastifyInstance, FastifyPluginCallback } from 'fastify'
import { Server } from 'http';
import { expectAssignable, expectError, expectType } from 'tsd'
import * as fastifyStaticStar from '../..';
import fastifyStatic, {
FastifyStaticOptions,
fastifyStatic as fastifyStaticNamed,
} from '../..'
import fastifyStaticCjsImport = require('../..');
const fastifyStaticCjs = require('../..');
const app: FastifyInstance = fastify();
app.register(fastifyStatic);
app.register(fastifyStaticNamed);
app.register(fastifyStaticCjs);
app.register(fastifyStaticCjsImport.default);
app.register(fastifyStaticCjsImport.fastifyStatic);
app.register(fastifyStaticStar.default);
app.register(fastifyStaticStar.fastifyStatic);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(fastifyStatic);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(fastifyStaticNamed);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(fastifyStaticCjsImport.default);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(fastifyStaticCjsImport.fastifyStatic);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(fastifyStaticStar.default);
expectType<FastifyPluginCallback<FastifyStaticOptions, Server>>(
fastifyStaticStar.fastifyStatic
);
expectType<any>(fastifyStaticCjs);
const appWithImplicitHttp = fastify()

@@ -6,0 +34,0 @@ const options: FastifyStaticOptions = {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc