Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-static

Package Overview
Dependencies
Maintainers
6
Versions
55
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 0.8.0 to 0.9.0

.npmignore

4

index.js

@@ -54,6 +54,2 @@ 'use strict'

fastify.get(prefix, function (req, reply) {
pumpSendToReply(req, reply, '/')
})
fastify.decorateReply('sendFile', function (filePath) {

@@ -60,0 +56,0 @@ pumpSendToReply(this.request, this, filePath)

{
"name": "fastify-static",
"version": "0.8.0",
"version": "0.9.0",
"description": "Plugin for serving static files as fast as possible.",

@@ -34,10 +34,10 @@ "main": "index.js",

"coveralls": "^3.0.0",
"fastify": "^0.43.0",
"fastify": "^1.1.1",
"pre-commit": "^1.2.2",
"proxyquire": "^1.8.0",
"request": "^2.81.0",
"proxyquire": "^2.0.0",
"request": "2.83.0",
"snazzy": "^7.0.0",
"standard": "^10.0.3",
"standard": "^11.0.0",
"tap": "^11.0.1"
}
}

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

t.test('register /static', t => {
t.plan(9)
t.plan(10)

@@ -41,2 +41,4 @@ const pluginOptions = {

t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {

@@ -147,2 +149,14 @@ t.error(err)

})
t.test('file not exposed outside of the plugin', t => {
t.plan(2)
request.get({
method: 'GET',
// foobar is in static
uri: 'http://localhost:' + fastify.server.address().port + '/foobar.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 404)
})
})
})

@@ -161,2 +175,4 @@ })

t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {

@@ -284,2 +300,4 @@ t.error(err)

t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {

@@ -321,2 +339,4 @@ t.error(err)

t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {

@@ -434,2 +454,4 @@ t.error(err)

t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {

@@ -517,1 +539,112 @@ t.error(err)

})
t.test('register no prefix', t => {
t.plan(8)
const pluginOptions = {
root: path.join(__dirname, '/static')
}
const fastify = require('fastify')()
fastify.register(fastifyStatic, pluginOptions)
fastify.get('/', (request, reply) => {
reply.send({ hello: 'world' })
})
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
t.test('/index.html', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/index.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body, indexContent)
genericResponseChecks(t, response)
})
})
t.test('/index.css', t => {
t.plan(2 + GENERIC_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/index.css'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
genericResponseChecks(t, response)
})
})
t.test('/', t => {
t.plan(3)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.deepEqual(JSON.parse(body), { hello: 'world' })
})
})
t.test('/deep/path/for/test/purpose/foo.html', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/deep/path/for/test/purpose/foo.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body, deepContent)
genericResponseChecks(t, response)
})
})
t.test('/deep/path/for/test/', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/deep/path/for/test/'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body, innerIndex)
genericResponseChecks(t, response)
})
})
t.test('/this/path/doesnt/exist.html', t => {
t.plan(2 + GENERIC_ERROR_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/this/path/doesnt/exist.html',
followRedirect: false
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 404)
genericErrorResponseChecks(t, response)
})
})
t.test('/../index.js', t => {
t.plan(2 + GENERIC_ERROR_RESPONSE_CHECK_COUNT)
request.get({
method: 'GET',
uri: 'http://localhost:' + fastify.server.address().port + '/../index.js',
followRedirect: false
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 403)
genericErrorResponseChecks(t, response)
})
})
})
})
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