Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-http-proxy

Package Overview
Dependencies
Maintainers
17
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-http-proxy - npm Package Compare versions

Comparing version 6.2.1 to 6.2.2

examples/example.js

10

index.d.ts

@@ -1,4 +0,4 @@

/// <reference types="node" />
/// <reference types='node' />
import { FastifyPlugin, preHandlerHookHandler } from "fastify";
import { FastifyPluginCallback, preHandlerHookHandler } from 'fastify';

@@ -8,5 +8,5 @@ import {

FastifyReplyFromHooks,
} from "fastify-reply-from";
} from 'fastify-reply-from';
import { ClientOptions, ServerOptions } from "ws";
import { ClientOptions, ServerOptions } from 'ws';

@@ -29,3 +29,3 @@ export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {

declare const fastifyHttpProxy: FastifyPlugin<FastifyHttpProxyOptions>;
export const fastifyHttpProxy: FastifyPluginCallback<FastifyHttpProxyOptions>;
export default fastifyHttpProxy;

@@ -187,3 +187,4 @@ 'use strict'

function handler (request, reply) {
let dest = request.raw.url
const queryParamIndex = request.raw.url.indexOf('?')
let dest = request.raw.url.slice(0, queryParamIndex !== -1 ? queryParamIndex : undefined)
dest = dest.replace(this.prefix, rewritePrefix)

@@ -190,0 +191,0 @@ reply.from(dest || '/', replyOpts)

{
"name": "fastify-http-proxy",
"version": "6.2.1",
"version": "6.2.2",
"description": "proxy http requests, for Fastify",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"lint:fix": "standard --fix",
"lint:typescript": "standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts",
"test": "standard | snazzy && tap test/*.js && npm run typescript",
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
"lint:typescript": "npm run lint:fix - --parser @typescript-eslint/parser --plugin typescript \"test/types/*.ts\"",
"test": "npm run lint && tap \"test/*.js\" && npm run typescript",
"typescript": "tsd"

@@ -29,31 +31,31 @@ },

"@fastify/pre-commit": "^2.0.2",
"@types/node": "^16.0.0",
"@types/ws": "^7.4.0",
"@typescript-eslint/parser": "^4.0.0",
"eslint-plugin-typescript": "^0.14.0",
"express": "^4.16.4",
"express-http-proxy": "^1.6.2",
"fast-proxy": "^2.0.0",
"fastify": "^3.12.0",
"@types/node": "^17.0.8",
"@types/ws": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"express": "^4.17.2",
"express-http-proxy": "^1.6.3",
"fast-proxy": "^2.1.0",
"fastify": "^3.25.3",
"fastify-websocket": "^4.0.0",
"got": "^11.5.1",
"http-errors": "^1.8.0",
"http-proxy": "^1.17.0",
"make-promises-safe": "^5.0.0",
"got": "^11.8.3",
"http-errors": "^2.0.0",
"http-proxy": "^1.18.1",
"make-promises-safe": "^5.1.0",
"simple-get": "^4.0.0",
"snazzy": "^9.0.0",
"socket.io": "^4.0.0",
"socket.io-client": "^4.0.0",
"standard": "^16.0.3",
"tap": "^15.0.1",
"tsd": "^0.17.0",
"typescript": "^4.0.2"
"socket.io": "^4.4.1",
"socket.io-client": "^4.4.1",
"standard": "^16.0.4",
"tap": "^15.1.6",
"tsd": "^0.19.1",
"typescript": "^4.5.4"
},
"dependencies": {
"fastify-reply-from": "^6.0.0",
"ws": "^8.0.0"
"fastify-reply-from": "^6.4.1",
"ws": "^8.4.2"
},
"tsd": {
"directory": "test"
"directory": "test/types"
}
}

@@ -73,3 +73,3 @@ # fastify-http-proxy

For other examples, see [`example.js`](example.js).
For other examples, see [`example.js`](examples/example.js).

@@ -76,0 +76,0 @@ ## Request tracking

@@ -657,4 +657,36 @@ 'use strict'

})
test('prefixed proxy with query search', async t => {
const appServer = Fastify()
appServer.get('/second-service', async (request, reply) => {
return `Hello World - lang = ${request.query.lang}`
})
appServer.get('/second-service/foo', async (request, reply) => {
return `Hello World (foo) - lang = ${request.query.lang}`
})
const address = await appServer.listen(0)
const proxyServer = Fastify()
proxyServer.register(proxy, {
upstream: `${address}/second-service`,
prefix: '/second-service'
})
const proxyAddress = await proxyServer.listen(0)
t.teardown(appServer.close.bind(appServer))
t.teardown(proxyServer.close.bind(proxyServer))
const resultRoot = await got(
`${proxyAddress}/second-service?lang=en`
)
t.equal(resultRoot.body, 'Hello World - lang = en')
const resultFooRoute = await got(
`${proxyAddress}/second-service/foo?lang=en`
)
t.equal(resultFooRoute.body, 'Hello World (foo) - lang = en')
})
}
run()

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc