Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fastify v4 compatibility #183

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ When you build plugins for Fastify and you want that them to be accessible in th
1. Use the `skip-override` hidden property
2. Use this module

__Note: the v4.x series of this module covers Fastify v4__
__Note: the v2.x & v3.x series of this module covers Fastify v3. For Fastify v2 support, refer to the v1.x series.__

## Usage
Expand Down Expand Up @@ -50,7 +51,7 @@ const fp = require('fastify-plugin')
module.exports = fp(function (fastify, opts, next) {
// your plugin code
next()
}, { fastify: '3.x' })
}, { fastify: '4.x' })
```

If you need to check the Fastify version only, you can pass just the version string.
Expand All @@ -69,7 +70,7 @@ function plugin (fastify, opts, next) {
}

module.exports = fp(plugin, {
fastify: '3.x',
fastify: '4.x',
name: 'your-plugin-name'
})
```
Expand All @@ -86,7 +87,7 @@ function plugin (fastify, opts, next) {
}

module.exports = fp(plugin, {
fastify: '3.x',
fastify: '4.x',
decorators: {
fastify: ['plugin1', 'plugin2'],
reply: ['compress']
Expand Down
2 changes: 1 addition & 1 deletion test/bundlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('webpack removes require.main.filename', (t) => {
fp((fastify, opts, next) => {
next()
}, {
fastify: '^3.0.0'
fastify: '^4.0.0'
})

t.end()
Expand Down
6 changes: 3 additions & 3 deletions test/checkVersion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('checkVersion having require.main.filename', (t) => {
fp((fastify, opts, next) => {
next()
}, {
fastify: '^3.0.0'
fastify: '^4.0.0'
})

t.end()
Expand All @@ -40,7 +40,7 @@ test('checkVersion having no require.main.filename but process.argv[1]', (t) =>
fp((fastify, opts, next) => {
next()
}, {
fastify: '^3.0.0'
fastify: '^4.0.0'
})

t.end()
Expand All @@ -66,7 +66,7 @@ test('checkVersion having no require.main.filename and no process.argv[1]', (t)
fp((fastify, opts, next) => {
next()
}, {
fastify: '^3.0.0'
fastify: '^4.0.0'
})

t.end()
Expand Down
12 changes: 6 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ test('should check fastify dependency graph - plugin', t => {
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'test',
dependencies: ['plugin1-name', 'plugin2-name']
}))
Expand All @@ -203,12 +203,12 @@ test('should check fastify dependency graph - decorate', t => {
const fastify = Fastify()

fastify.decorate('plugin1', fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'test',
decorators: { fastify: ['plugin1', 'plugin2'] }
}))
Expand All @@ -223,12 +223,12 @@ test('should check fastify dependency graph - decorateReply', t => {
const fastify = Fastify()

fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '3.x',
fastify: '4.x',
name: 'test',
decorators: { reply: ['plugin1', 'plugin2'] }
}))
Expand Down