New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/static

Package Overview
Dependencies
Maintainers
20
Versions
36
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 8.0.2 to 8.0.3

test/static-symbolic-link/dir/symlink

3

index.js

@@ -41,2 +41,3 @@ 'use strict'

acceptRanges: opts.acceptRanges,
contentType: opts.contentType,
cacheControl: opts.cacheControl,

@@ -476,3 +477,3 @@ dotfiles: opts.dotfiles,

}
return `${type}; charset=UTF-8`
return `${type}; charset=utf-8`
}

@@ -479,0 +480,0 @@

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

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

"@fastify/accept-negotiator": "^2.0.0",
"@fastify/send": "^3.1.0",
"@fastify/send": "^3.2.0",
"content-disposition": "^0.5.4",

@@ -46,3 +46,3 @@ "fastify-plugin": "^5.0.0",

"eslint": "^9.9.0",
"fastify": "^5.0.0",
"fastify": "^5.1.0",
"neostandard": "^0.11.3",

@@ -49,0 +49,0 @@ "pino": "^9.1.0",

@@ -156,13 +156,14 @@ # @fastify/static

The following options are also supported and will be passed directly to the
[`send`](https://www.npmjs.com/package/send) module:
[`@fastify/send`](https://www.npmjs.com/package/@fastify/send) module:
- [`acceptRanges`](https://www.npmjs.com/package/send#acceptranges)
- [`cacheControl`](https://www.npmjs.com/package/send#cachecontrol)
- [`dotfiles`](https://www.npmjs.com/package/send#dotfiles)
- [`etag`](https://www.npmjs.com/package/send#etag)
- [`extensions`](https://www.npmjs.com/package/send#extensions)
- [`immutable`](https://www.npmjs.com/package/send#immutable)
- [`index`](https://www.npmjs.com/package/send#index)
- [`lastModified`](https://www.npmjs.com/package/send#lastmodified)
- [`maxAge`](https://www.npmjs.com/package/send#maxage)
- [`acceptRanges`](https://www.npmjs.com/package/@fastify/send#acceptranges)
- [`contentType`](https://www.npmjs.com/package/@fastify/send#contenttype)
- [`cacheControl`](https://www.npmjs.com/package/@fastify/send#cachecontrol) (Enable or disable setting Cache-Control response header, defaults to true. **Important:** If you want to provide a custom Cache-Control response header, this option must be false.)
- [`dotfiles`](https://www.npmjs.com/package/@fastify/send#dotfiles)
- [`etag`](https://www.npmjs.com/package/@fastify/send#etag)
- [`extensions`](https://www.npmjs.com/package/@fastify/send#extensions)
- [`immutable`](https://www.npmjs.com/package/@fastify/send#immutable)
- [`index`](https://www.npmjs.com/package/@fastify/send#index)
- [`lastModified`](https://www.npmjs.com/package/@fastify/send#lastmodified)
- [`maxAge`](https://www.npmjs.com/package/@fastify/send#maxage)

@@ -202,3 +203,3 @@ You're able to alter this options when calling `reply.download('filename.html', options)` or `reply.download('filename.html', 'otherfilename.html', options)` on each response to a request.

This function allows filtering the served files. Also, with the help of the request object a more complex path authentication is possible.
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.

@@ -211,3 +212,3 @@ If the function returns `false`, Fastify's 404 handler will be called.

Under the hood we use [send](https://github.com/pillarjs/send#index) lib that by default supports "index.html" files.
Under the hood we use [send](https://github.com/pillarjs/send#index) lib that by default supports "index.html" files.
To disable this set false or to supply a new index pass a string or an array in preferred order.

@@ -475,3 +476,3 @@

This code will send the `index.html` for the paths `docs`, `docs/`, and `docs/index.html`. For all other `docs/<undefined-routes>` it will reply with `404.html`.
This code will send the `index.html` for the paths `docs`, `docs/`, and `docs/index.html`. For all other `docs/<undefined-routes>` it will reply with `404.html`.

@@ -478,0 +479,0 @@ ### Handling Errors

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

t.error(err)
t.equal(response.headers['content-type'], 'text/html; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/html; charset=utf-8')
})

@@ -48,3 +48,3 @@ })

t.error(err)
t.equal(response.headers['content-type'], 'text/css; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/css; charset=utf-8')
})

@@ -71,3 +71,3 @@ })

t.error(err)
t.equal(response.headers['content-type'], 'text/plain; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/plain; charset=utf-8')
})

@@ -117,3 +117,3 @@ })

t.error(err)
t.equal(response.headers['content-type'], 'text/html; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/html; charset=utf-8')
})

@@ -132,3 +132,3 @@ })

t.error(err)
t.equal(response.headers['content-type'], 'text/css; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/css; charset=utf-8')
})

@@ -161,3 +161,3 @@ })

t.error(err)
t.equal(response.headers['content-type'], 'text/plain; charset=UTF-8')
t.equal(response.headers['content-type'], 'text/plain; charset=utf-8')
})

@@ -164,0 +164,0 @@ })

@@ -75,2 +75,3 @@ // Definitions by: Jannik <https://github.com/jannikkeye>

acceptRanges?: boolean;
contentType?: boolean;
cacheControl?: boolean;

@@ -107,2 +108,3 @@ dotfiles?: 'allow' | 'deny' | 'ignore';

acceptRanges?: boolean;
contentType?: boolean;
cacheControl?: boolean;

@@ -109,0 +111,0 @@ dotfiles?: 'allow' | 'deny' | 'ignore';

@@ -16,9 +16,9 @@ import fastify, { FastifyInstance, FastifyPluginAsync, FastifyRequest, FastifyReply } from '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)
app.register(fastifyStatic, { root: __dirname })
app.register(fastifyStaticNamed, { root: __dirname })
app.register(fastifyStaticCjs, { root: __dirname })
app.register(fastifyStaticCjsImport.default, { root: __dirname })
app.register(fastifyStaticCjsImport.fastifyStatic, { root: __dirname })
app.register(fastifyStaticStar.default, { root: __dirname })
app.register(fastifyStaticStar.fastifyStatic, { root: __dirname })

@@ -38,2 +38,3 @@ expectType<FastifyPluginAsync<FastifyStaticOptions, Server>>(fastifyStatic)

acceptRanges: true,
contentType: true,
cacheControl: true,

@@ -150,2 +151,6 @@ decorateReply: true,

})
appWithHttp2.get('/download/3', (request, reply) => {
reply.download('some-file-name', 'some-filename', { contentType: false })
})
})

@@ -171,2 +176,6 @@

multiRootAppWithImplicitHttp.get('/', (request, reply) => {
reply.sendFile('some-file-name', 'some-root-name-2', { contentType: false })
})
multiRootAppWithImplicitHttp.get('/download', (request, reply) => {

@@ -183,2 +192,6 @@ reply.download('some-file-name')

})
multiRootAppWithImplicitHttp.get('/download/3', (request, reply) => {
reply.download('some-file-name', 'some-filename', { contentType: false })
})
})

@@ -185,0 +198,0 @@

Sorry, the diff of this file is not supported yet

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