fastify-plugin
Advanced tools
Comparing version 4.5.1 to 5.0.0-pre.fv5.1
{ | ||
"name": "fastify-plugin", | ||
"version": "4.5.1", | ||
"version": "5.0.0-pre.fv5.1", | ||
"description": "Plugin helper for Fastify", | ||
"main": "plugin.js", | ||
"type": "commonjs", | ||
"types": "types/plugin.d.ts", | ||
@@ -29,10 +30,11 @@ "scripts": { | ||
"devDependencies": { | ||
"@fastify/type-provider-typebox": "^3.0.0", | ||
"@types/node": "^20.1.0", | ||
"fastify": "^4.0.1", | ||
"@fastify/pre-commit": "^2.1.0", | ||
"@fastify/type-provider-typebox": "^5.0.0-pre.fv5.1", | ||
"@types/node": "^20.11.20", | ||
"fastify": "^5.0.0-alpha.2", | ||
"proxyquire": "^2.1.3", | ||
"standard": "^17.0.0", | ||
"tap": "^16.0.1", | ||
"tsd": "^0.28.0" | ||
"standard": "^17.1.0", | ||
"tap": "^18.7.0", | ||
"tsd": "^0.31.0" | ||
} | ||
} |
@@ -11,3 +11,3 @@ 'use strict' | ||
if (typeof fn.default !== 'undefined') { | ||
if (fn.default !== undefined) { | ||
// Support for 'export default' behaviour in transpiled ECMAScript module | ||
@@ -14,0 +14,0 @@ fn = fn.default |
@@ -9,3 +9,3 @@ # fastify-plugin | ||
When you build plugins for Fastify and you want that them to be accessible in the same context where you require them, you have two ways: | ||
When you build plugins for Fastify and you want them to be accessible in the same context where you require them, you have two ways: | ||
1. Use the `skip-override` hidden property | ||
@@ -17,2 +17,8 @@ 2. Use this module | ||
## Install | ||
```sh | ||
npm i fastify-plugin | ||
``` | ||
## Usage | ||
@@ -141,3 +147,3 @@ `fastify-plugin` can do three things for you: | ||
TypeScript can sometimes infer the types of the arguments for these functions. Plugins in fastify are recommended to be typed using either `FastifyPluginCallback` or `FastifyPluginAsync`. These two definitions only differ in two ways: | ||
TypeScript can sometimes infer the types of the arguments for these functions. Plugins in Fastify are recommended to be typed using either `FastifyPluginCallback` or `FastifyPluginAsync`. These two definitions only differ in two ways: | ||
@@ -144,0 +150,0 @@ 1. The third argument `done` (the callback part) |
@@ -9,2 +9,4 @@ 'use strict' | ||
const pkg = require('../package.json') | ||
test('fastify-plugin is a function', t => { | ||
@@ -210,3 +212,3 @@ t.plan(1) | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'plugin1-name' | ||
@@ -216,3 +218,3 @@ })) | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'test', | ||
@@ -232,3 +234,3 @@ dependencies: ['plugin1-name', 'plugin2-name'] | ||
fastify.decorate('plugin1', fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'plugin1-name' | ||
@@ -238,3 +240,3 @@ })) | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'test', | ||
@@ -254,3 +256,3 @@ decorators: { fastify: ['plugin1', 'plugin2'] } | ||
fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'plugin1-name' | ||
@@ -260,3 +262,3 @@ })) | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'test', | ||
@@ -321,16 +323,20 @@ decorators: { reply: ['plugin1', 'plugin2'] } | ||
test('should check version when encapsulated', t => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
test( | ||
'should check version when encapsulated', | ||
{ skip: /\d-.+/.test(pkg.devDependencies.fastify) }, | ||
t => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
name: 'test', | ||
fastify: '<=2.10.0', | ||
encapsulate: true | ||
})) | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
name: 'test', | ||
fastify: '<=2.10.0', | ||
encapsulate: true | ||
})) | ||
fastify.ready(err => { | ||
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/) | ||
}) | ||
}) | ||
fastify.ready(err => { | ||
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/) | ||
}) | ||
} | ||
) | ||
@@ -344,3 +350,3 @@ test('should check decorators when encapsulated', t => { | ||
fastify.register(fp((fastify, opts, next) => next(), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'test', | ||
@@ -364,3 +370,3 @@ encapsulate: true, | ||
fastify.register(fp(getFn('hello'), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'hello', | ||
@@ -372,3 +378,3 @@ encapsulate: true | ||
fastify.register(fp(getFn('deep'), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'deep', | ||
@@ -382,3 +388,3 @@ encapsulate: true | ||
fastify.register(fp(getFn('deep-deep-deep'), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'deep-deep-deep', | ||
@@ -389,3 +395,3 @@ encapsulate: true | ||
fastify.register(fp(getFn('deep-deep -> not-encapsulated-2'), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'not-encapsulated-2' | ||
@@ -396,3 +402,3 @@ })) | ||
}, { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'deep-deep', | ||
@@ -403,3 +409,3 @@ encapsulate: true | ||
fastify.register(fp(getFn('plugin -> not-encapsulated'), { | ||
fastify: '4.x', | ||
fastify: '5.x', | ||
name: 'not-encapsulated' | ||
@@ -406,0 +412,0 @@ })) |
@@ -13,3 +13,2 @@ /// <reference types="fastify" /> | ||
} from 'fastify' | ||
import { IncomingMessage, Server, ServerResponse } from 'http' | ||
@@ -16,0 +15,0 @@ type FastifyPlugin = typeof fastifyPlugin |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40499
24
870
189
8
1
1