diff --git a/index.js b/index.js index 1f5b8d7..ce0348a 100644 --- a/index.js +++ b/index.js @@ -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', { diff --git a/package.json b/package.json index 74df80c..848dc7b 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/static.test.js b/test/static.test.js index 7480927..3138101 100644 --- a/test/static.test.js +++ b/test/static.test.js @@ -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) +})