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

fastify-static

Package Overview
Dependencies
Maintainers
7
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.10.1 to 0.11.0

.npmignore

4

index.js

@@ -82,4 +82,6 @@ 'use strict'

const prefix = opts.prefix[opts.prefix.length - 1] === '/' ? opts.prefix : (opts.prefix + '/')
// Set the schema hide property if defined in opts or true by default
const schema = { schema: { hide: typeof opts.schemaHide !== 'undefined' ? opts.schemaHide : true } }
fastify.get(prefix + '*', function (req, reply) {
fastify.get(prefix + '*', schema, function (req, reply) {
pumpSendToReply(req, reply, '/' + req.params['*'])

@@ -86,0 +88,0 @@ })

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

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

"coveralls": "^3.0.0",
"fastify": "^1.1.1",
"fastify-compress": "^0.5.1",
"fastify": "^1.3.0",
"fastify-compress": "^0.6.0",
"pre-commit": "^1.2.2",
"proxyquire": "^2.0.0",
"simple-get": "^2.7.0",
"simple-get": "^3.0.1",
"snazzy": "^7.0.0",

@@ -42,0 +42,0 @@ "standard": "^11.0.0",

@@ -41,2 +41,8 @@ # fastify-static

#### `schemaHide`
Default: `true`
A flag that define if the fastify route hide-schema attribute is hidden or not
#### `setHeaders`

@@ -43,0 +49,0 @@

@@ -718,1 +718,120 @@ 'use strict'

})
t.test('register /static/ with schemaHide true', t => {
t.plan(3)
const pluginOptions = {
root: path.join(__dirname, '/static'),
prefix: '/static/',
schemaHide: true
}
const fastify = Fastify()
fastify.addHook('onRoute', function (routeOptions) {
t.deepEqual(routeOptions.schema, { hide: true })
})
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
t.test('/static/index.html', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
simple.concat({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/static/index.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body.toString(), indexContent)
genericResponseChecks(t, response)
})
})
})
})
t.test('register /static/ with schemaHide false', t => {
t.plan(3)
const pluginOptions = {
root: path.join(__dirname, '/static'),
prefix: '/static/',
schemaHide: false
}
const fastify = Fastify()
fastify.addHook('onRoute', function (routeOptions) {
t.deepEqual(routeOptions.schema, { hide: false })
})
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
t.test('/static/index.html', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
simple.concat({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/static/index.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body.toString(), indexContent)
genericResponseChecks(t, response)
})
})
})
})
t.test('register /static/ without schemaHide', t => {
t.plan(3)
const pluginOptions = {
root: path.join(__dirname, '/static'),
prefix: '/static/'
}
const fastify = Fastify()
fastify.addHook('onRoute', function (routeOptions) {
t.deepEqual(routeOptions.schema, { hide: true })
})
fastify.register(fastifyStatic, pluginOptions)
t.tearDown(fastify.close.bind(fastify))
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
t.test('/static/index.html', t => {
t.plan(3 + GENERIC_RESPONSE_CHECK_COUNT)
simple.concat({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/static/index.html'
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(body.toString(), indexContent)
genericResponseChecks(t, response)
})
})
})
})

Sorry, the diff of this file is not supported yet

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