Skip to content

Commit 5658d3e

Browse files
authored
Merge pull request #18 from fastify/fastify-next
Update for fastify v2
2 parents 5c7aade + e70fc73 commit 5658d3e

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
that provides mechanisms for manipulating HTTP cache headers according to
77
[RFC 2616 §14.9](https://tools.ietf.org/html/rfc2616#section-14.9).
88

9-
Supports Fastify versions ^1.0.0.
9+
Supports Fastify versions ^2.0.0.
1010

1111
This plugin fully supports Fastify's encapsulation. Therefore, routes that
1212
should have differing cache settings should be registered within different

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/fastify/fastify-caching#readme",
3131
"devDependencies": {
32-
"fastify": "^1.13.0",
32+
"fastify": "2.0.0-rc.0",
3333
"pre-commit": "^1.2.2",
3434
"snazzy": "^8.0.0",
3535
"standard": "^12.0.1",

plugin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ function etagHandleRequest (req, res, next) {
3333
this.cache.get({ id: etag, segment: this.cacheSegment }, (err, cached) => {
3434
if (err) return next(err)
3535
if (cached && cached.item) {
36-
res.statusCode = 304
37-
return res.end()
36+
return res.status(304).send()
3837
}
3938
next()
4039
})
@@ -86,7 +85,7 @@ function fastifyCachingPlugin (instance, options, next) {
8685
}
8786

8887
module.exports = fp(fastifyCachingPlugin, {
89-
fastify: '^1.0.0',
88+
fastify: '^2.0.0',
9089
name: 'fastify-caching'
9190
})
9291

0 commit comments

Comments
 (0)