Skip to content

Commit

Permalink
Removed socket prop from the stream wrap (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Oct 4, 2020
1 parent 9d6ef4d commit ca9da85
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function fastifyStatic (fastify, opts, next) {

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

Object.defineProperty(wrap, 'filename', {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
},
"homepage": "https://github.com/fastify/fastify-static",
"dependencies": {
"fastify-plugin": "^2.0.0",
"fastify-plugin": "^2.3.4",
"glob": "^7.1.4",
"readable-stream": "^3.4.0",
"send": "^0.17.1"
},
"devDependencies": {
"@types/node": "^14.0.1",
"@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"concat-stream": "^2.0.0",
"coveralls": "^3.0.4",
"eslint-plugin-typescript": "^0.14.0",
"fastify": "^3.0.0",
"fastify-compress": "^3.0.0",
"fastify-compress": "^3.3.1",
"handlebars": "^4.7.6",
"pre-commit": "^1.2.2",
"proxyquire": "^2.1.0",
"simple-get": "^4.0.0",
"snazzy": "^8.0.0",
"standard": "^14.0.0",
"tap": "^14.10.7",
"tap": "^14.10.8",
"tsd": "^0.13.1",
"typescript": "^4.0.2"
},
Expand Down
17 changes: 17 additions & 0 deletions test/static.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2158,3 +2158,20 @@ t.test('register with rootpath that causes statSync to fail with non-ENOENT code
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)
})

0 comments on commit ca9da85

Please sign in to comment.