fastify-http-proxy
Advanced tools
Comparing version 4.0.2 to 4.0.3
/// <reference types="node" /> | ||
import { | ||
FastifyRequest, | ||
RawServerBase, | ||
FastifyPlugin, | ||
FastifyError, | ||
FastifyReply | ||
preHandlerHookHandler | ||
} from "fastify"; | ||
@@ -17,12 +14,4 @@ | ||
proxyPayloads?: boolean; | ||
preHandler?: ( | ||
request: FastifyRequest<RawServerBase>, | ||
reply: FastifyReply<RawServerBase>, | ||
next: (err?: FastifyError | undefined) => void | ||
) => void; | ||
beforeHandler?: ( | ||
request: FastifyRequest<RawServerBase>, | ||
reply: FastifyReply<RawServerBase>, | ||
next: (err?: FastifyError | undefined) => void | ||
) => void; | ||
preHandler?: preHandlerHookHandler; | ||
beforeHandler?: preHandlerHookHandler; | ||
config?: Object; | ||
@@ -29,0 +18,0 @@ replyOptions?: Object; |
{ | ||
"name": "fastify-http-proxy", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "proxy http requests, for Fastify", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "standard | snazzy && tap test/*.js", | ||
"test": "standard | snazzy && tap test/*.js && npm run typescript", | ||
"lint:typescript": "standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts", | ||
@@ -27,9 +27,9 @@ "typescript": "tsd" | ||
"devDependencies": { | ||
"@types/node": "^14.0.18", | ||
"@typescript-eslint/parser": "^3.6.0", | ||
"@types/node": "^14.0.27", | ||
"@typescript-eslint/parser": "^3.8.0", | ||
"eslint-plugin-typescript": "^0.14.0", | ||
"express": "^4.16.4", | ||
"express-http-proxy": "^1.5.0", | ||
"express-http-proxy": "^1.6.2", | ||
"fastify": "^3.0.0", | ||
"got": "^11.4.0", | ||
"got": "^11.5.1", | ||
"http-errors": "^1.8.0", | ||
@@ -42,9 +42,9 @@ "http-proxy": "^1.17.0", | ||
"standard": "^14.0.2", | ||
"tap": "^14.0.0", | ||
"tap": "^14.10.8", | ||
"tsd": "^0.13.1", | ||
"typescript": "^3.9.6" | ||
"typescript": "^3.9.7" | ||
}, | ||
"dependencies": { | ||
"fastify-reply-from": "^3.1.2", | ||
"fastify-websocket": "^2.0.3", | ||
"fastify-reply-from": "^3.1.3", | ||
"fastify-websocket": "^2.0.7", | ||
"ws": "^7.3.1" | ||
@@ -51,0 +51,0 @@ }, |
@@ -49,2 +49,3 @@ # fastify-http-proxy | ||
// /api/x will be proxied to http://my-api.example.com/x | ||
server.register(proxy, { | ||
@@ -56,5 +57,7 @@ upstream: 'http://my-api.example.com', | ||
// /auth/user will be proxied to http://single-signon.example.com/signon/user | ||
server.register(proxy, { | ||
upstream: 'http://single-signon.example.com/auth', | ||
upstream: 'http://single-signon.example.com', | ||
prefix: '/auth', // optional | ||
rewritePrefix: '/signon', // optional | ||
http2: false // optional | ||
@@ -68,2 +71,4 @@ }) | ||
Also notice paths in `upstream` are ignored, so you need to use `rewritePrefix` to specify the target base path. | ||
For other examples, see `example.js`. | ||
@@ -70,0 +75,0 @@ |
@@ -1,6 +0,4 @@ | ||
import fastify from "fastify"; | ||
import fastify, { RawReplyDefaultExpression, RawRequestDefaultExpression } from "fastify"; | ||
import fastifyHttpProxy from ".."; | ||
import { expectType } from "tsd"; | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
import { Http2ServerRequest, Http2ServerResponse } from "http2"; | ||
@@ -21,9 +19,9 @@ const app = fastify(); | ||
preHandler: (request, reply) => { | ||
expectType<IncomingMessage | Http2ServerRequest>(request.raw); | ||
expectType<ServerResponse | Http2ServerResponse>(reply.raw); | ||
expectType<RawRequestDefaultExpression>(request.raw); | ||
expectType<RawReplyDefaultExpression>(reply.raw); | ||
}, | ||
beforeHandler: (request, reply) => { | ||
expectType<IncomingMessage | Http2ServerRequest>(request.raw); | ||
expectType<ServerResponse | Http2ServerResponse>(reply.raw); | ||
expectType<RawRequestDefaultExpression>(request.raw); | ||
expectType<RawReplyDefaultExpression>(reply.raw); | ||
} | ||
}); |
@@ -350,4 +350,30 @@ 'use strict' | ||
}) | ||
test('undici POST', async t => { | ||
const proxyServer = Fastify() | ||
proxyServer.register(proxy, { | ||
upstream: `http://localhost:${origin.server.address().port}`, | ||
undici: true | ||
}) | ||
await proxyServer.listen(0) | ||
t.tearDown(() => { | ||
proxyServer.close() | ||
}) | ||
const { | ||
headers: { location } | ||
} = await got( | ||
`http://localhost:${proxyServer.server.address().port}/this-has-data`, | ||
{ | ||
method: 'POST', | ||
json: { hello: 'world' } | ||
} | ||
) | ||
t.equal(location, '/something') | ||
}) | ||
} | ||
run() |
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
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
25224
578
162
Updatedfastify-reply-from@^3.1.3
Updatedfastify-websocket@^2.0.7