Skip to content

Commit 14292d1

Browse files
authored
Merge pull request #7 from lependu/update-dependencies
Updates dependencies, plugin-meta
2 parents 8fc0eda + 70ff46c commit 14292d1

File tree

4 files changed

+22
-37
lines changed

4 files changed

+22
-37
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
},
3030
"homepage": "https://github.com/fastify/fastify-caching#readme",
3131
"devDependencies": {
32-
"fastify": "^0.35.2",
32+
"fastify": "^0.39.1",
3333
"pre-commit": "^1.2.2",
3434
"snazzy": "^7.0.0",
3535
"standard": "^10.0.3",
36-
"tap": "^10.7.3"
36+
"tap": "^11.0.1"
3737
},
3838
"dependencies": {
3939
"abstract-cache": "^1.0.0",
40-
"fastify-plugin": "^0.1.1",
40+
"fastify-plugin": "^0.2.1",
4141
"uid-safe": "^2.1.5"
4242
}
4343
}

plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ function fastifyCachingPlugin (instance, options, next) {
8383
next()
8484
}
8585

86-
module.exports = fp(fastifyCachingPlugin, '>=0.33.0')
86+
module.exports = fp(fastifyCachingPlugin, {
87+
fastify: '>=0.39.1',
88+
name: 'fastify-caching'
89+
})
8790

8891
module.exports.privacy = {
8992
NOCACHE: 'no-cache',

test/cache.test.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ const fastify = require('fastify')
99
test('cache property gets added to instance', (t) => {
1010
t.plan(2)
1111
const instance = fastify()
12-
instance.register(plugin, (err) => {
13-
if (err) t.threw(err)
14-
15-
t.ok(instance.cache)
16-
t.ok(instance.cache.set)
17-
})
12+
instance
13+
.register(plugin)
14+
.ready(() => {
15+
t.ok(instance.cache)
16+
t.ok(instance.cache.set)
17+
})
1818
})
1919

2020
test('cache is usable', (t) => {
2121
t.plan(1)
2222
const instance = fastify()
23-
instance.register(plugin, (err) => {
24-
if (err) t.threw(err)
25-
})
23+
instance.register(plugin)
2624

2725
instance.get('/one', (req, reply) => {
2826
instance.cache.set('one', {one: true}, 100, (err) => {
@@ -57,9 +55,7 @@ test('cache is usable', (t) => {
5755
test('etags get stored in cache', (t) => {
5856
t.plan(1)
5957
const instance = fastify()
60-
instance.register(plugin, (err) => {
61-
if (err) t.threw(err)
62-
})
58+
instance.register(plugin)
6359

6460
instance.get('/one', (req, reply) => {
6561
reply
@@ -95,9 +91,7 @@ test('etags get stored in cache', (t) => {
9591
test('etag cache life is customizable', (t) => {
9692
t.plan(1)
9793
const instance = fastify()
98-
instance.register(plugin, (err) => {
99-
if (err) t.threw(err)
100-
})
94+
instance.register(plugin)
10195

10296
instance.get('/one', function (req, reply) {
10397
reply

test/headers.test.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const fastify = require('fastify')
88
test('decorators get added', (t) => {
99
t.plan(1)
1010
const instance = fastify()
11-
instance.register(plugin, (err) => {
12-
if (err) t.threw(err)
13-
})
11+
instance.register(plugin)
1412
instance.get('/', (req, reply) => {
1513
t.ok(reply.etag)
1614
reply.send()
@@ -28,9 +26,7 @@ test('decorators add headers', (t) => {
2826
t.plan(2)
2927
const tag = '123456'
3028
const instance = fastify()
31-
instance.register(plugin, (err) => {
32-
if (err) t.threw(err)
33-
})
29+
instance.register(plugin)
3430
instance.get('/', (req, reply) => {
3531
reply
3632
.etag(tag)
@@ -51,9 +47,7 @@ test('decorators add headers', (t) => {
5147
test('sets no-cache header', (t) => {
5248
t.plan(2)
5349
const instance = fastify()
54-
instance.register(plugin, {privacy: plugin.privacy.NOCACHE}, (err) => {
55-
if (err) t.threw(err)
56-
})
50+
instance.register(plugin, {privacy: plugin.privacy.NOCACHE})
5751
instance.get('/', (req, reply) => {
5852
reply.send({hello: 'world'})
5953
})
@@ -77,9 +71,7 @@ test('sets private with max-age header', (t) => {
7771
privacy: plugin.privacy.PRIVATE,
7872
expiresIn: 300
7973
}
80-
instance.register(plugin, opts, (err) => {
81-
if (err) t.threw(err)
82-
})
74+
instance.register(plugin, opts)
8375
instance.get('/', (req, reply) => {
8476
reply.send({hello: 'world'})
8577
})
@@ -99,9 +91,7 @@ test('sets private with max-age header', (t) => {
9991
test('sets no-store with max-age header', (t) => {
10092
t.plan(2)
10193
const instance = fastify()
102-
instance.register(plugin, {privacy: 'no-store', expiresIn: 300}, (err) => {
103-
if (err) t.threw(err)
104-
})
94+
instance.register(plugin, {privacy: 'no-store', expiresIn: 300})
10595
instance.get('/', (req, reply) => {
10696
reply.send({hello: 'world'})
10797
})
@@ -122,9 +112,7 @@ test('sets the expires header', (t) => {
122112
t.plan(2)
123113
const now = new Date()
124114
const instance = fastify()
125-
instance.register(plugin, {privacy: plugin.privacy.NOCACHE}, (err) => {
126-
if (err) t.threw(err)
127-
})
115+
instance.register(plugin, {privacy: plugin.privacy.NOCACHE})
128116
instance.get('/', (req, reply) => {
129117
reply
130118
.expires(now)

0 commit comments

Comments
 (0)