diff --git a/index.js b/index.js index d0f24a6..93400fe 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ const From = require('@fastify/reply-from') const WebSocket = require('ws') const { convertUrlToWebSocket } = require('./utils') +const fp = require('fastify-plugin') const httpMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT', 'OPTIONS'] const urlPattern = /^https?:\/\// @@ -261,11 +262,10 @@ async function fastifyHttpProxy (fastify, opts) { } } -fastifyHttpProxy[Symbol.for('plugin-meta')] = { +module.exports = fp(fastifyHttpProxy, { fastify: '4.x', - name: '@fastify/http-proxy' -} - -module.exports = fastifyHttpProxy + name: '@fastify/http-proxy', + encapsulate: true +}) module.exports.default = fastifyHttpProxy module.exports.fastifyHttpProxy = fastifyHttpProxy diff --git a/package.json b/package.json index 9c95c27..6b1a904 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ }, "dependencies": { "@fastify/reply-from": "^8.0.0", + "fastify-plugin": "^4.5.0", "ws": "^8.4.2" }, "tsd": {