Socket
Socket
Sign inDemoInstall

fastify-static

Package Overview
Dependencies
34
Maintainers
8
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.0 to 3.2.1

1

index.js

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

wrap.setHeader = reply.header.bind(reply)
wrap.socket = request.raw.socket
wrap.finished = false

@@ -69,0 +68,0 @@

12

package.json
{
"name": "fastify-static",
"version": "3.2.0",
"version": "3.2.1",
"description": "Plugin for serving static files as fast as possible.",

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

"dependencies": {
"fastify-plugin": "^2.0.0",
"fastify-plugin": "^2.3.4",
"glob": "^7.1.4",

@@ -38,3 +38,3 @@ "readable-stream": "^3.4.0",

"devDependencies": {
"@types/node": "^14.0.1",
"@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^2.29.0",

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

"fastify": "^3.0.0",
"fastify-compress": "^3.0.0",
"fastify-compress": "^3.3.1",
"handlebars": "^4.7.6",

@@ -54,5 +54,5 @@ "pre-commit": "^1.2.2",

"standard": "^14.0.0",
"tap": "^14.10.7",
"tap": "^14.10.8",
"tsd": "^0.13.1",
"typescript": "^3.5.2"
"typescript": "^4.0.2"
},

@@ -59,0 +59,0 @@ "tsd": {

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

const pino = require('pino')
const proxyquire = require('proxyquire')

@@ -827,3 +828,3 @@ const fastifyStatic = require('../')

t.strictEqual(options.maxAge, 'maxAge')
return { on: () => {}, pipe: () => {} }
return { on: () => { }, pipe: () => { } }
}

@@ -2112,1 +2113,68 @@ })

})
t.test('register with failing glob handler', t => {
const fastifyStatic = proxyquire.noCallThru()('../', {
glob: function globStub (pattern, options, cb) {
process.nextTick(function () {
return cb(new Error('mock glob error'))
})
}
})
const pluginOptions = {
root: path.join(__dirname, '/static'),
serve: true,
wildcard: '*'
}
const fastify = Fastify()
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
fastify.server.unref()
t.ok(err)
t.end()
})
})
t.test('register with rootpath that causes statSync to fail with non-ENOENT code', t => {
const fastifyStatic = proxyquire('../', {
fs: {
statSync: function statSyncStub (path) {
throw new Error({ code: 'MOCK' })
}
}
})
const pluginOptions = {
root: path.join(__dirname, '/static'),
wildcard: '*'
}
const fastify = Fastify()
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
fastify.server.unref()
t.ok(err)
t.end()
})
})
t.test('inject support', async (t) => {
const pluginOptions = {
root: path.join(__dirname, '/static'),
prefix: '/static'
}
const fastify = Fastify()
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
const response = await fastify.inject({
method: 'GET',
url: '/static/index.html'
})
t.strictEqual(response.statusCode, 200)
t.strictEqual(response.body.toString(), indexContent)
})
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc