fastify-http-proxy
Advanced tools
Comparing version 3.2.0 to 4.0.0
/// <reference types="node" /> | ||
import { | ||
FastifyRequest, | ||
Plugin, | ||
DefaultQuery, | ||
DefaultParams, | ||
DefaultHeaders, | ||
RawServerBase, | ||
FastifyPlugin, | ||
FastifyError, | ||
FastifyReply | ||
} from "fastify"; | ||
import { Server, IncomingMessage, ServerResponse } from "http"; | ||
import { Http2ServerRequest, Http2ServerResponse } from "http2"; | ||
type HttpRequest = IncomingMessage | Http2ServerRequest; | ||
type HttpResponse = ServerResponse | Http2ServerResponse; | ||
export interface FastifyHttpProxyOptions { | ||
upstream: string; | ||
prefix?: string; | ||
rewritePrefix?: string; | ||
http2?: boolean; | ||
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; | ||
config?: Object; | ||
replyOptions?: Object; | ||
} | ||
declare const fastifyHttpProxy: Plugin< | ||
Server, | ||
IncomingMessage, | ||
ServerResponse, | ||
{ | ||
upstream: string; | ||
prefix?: string; | ||
rewritePrefix?: string; | ||
http2?: boolean; | ||
proxyPayloads?: boolean; | ||
preHandler?: ( | ||
request: FastifyRequest< | ||
HttpRequest, | ||
DefaultQuery, | ||
DefaultParams, | ||
DefaultHeaders, | ||
any | ||
>, | ||
reply: FastifyReply<HttpResponse>, | ||
next: (err?: FastifyError | undefined) => void | ||
) => void; | ||
beforeHandler?: ( | ||
request: FastifyRequest< | ||
HttpRequest, | ||
DefaultQuery, | ||
DefaultParams, | ||
DefaultHeaders, | ||
any | ||
>, | ||
reply: FastifyReply<HttpResponse>, | ||
next: (err?: FastifyError | undefined) => void | ||
) => void; | ||
config?: Object; | ||
replyOptions?: Object; | ||
} | ||
>; | ||
export = fastifyHttpProxy; | ||
declare const fastifyHttpProxy: FastifyPlugin<FastifyHttpProxyOptions>; | ||
export default fastifyHttpProxy; |
@@ -45,4 +45,4 @@ 'use strict' | ||
function bodyParser (req, done) { | ||
done(null, req) | ||
function bodyParser (req, payload, done) { | ||
done(null, payload) | ||
} | ||
@@ -83,3 +83,3 @@ | ||
function handler (request, reply) { | ||
var dest = request.req.url | ||
var dest = request.raw.url | ||
dest = dest.replace(this.prefix, rewritePrefix) | ||
@@ -86,0 +86,0 @@ reply.from(dest || '/', replyOpts) |
{ | ||
"name": "fastify-http-proxy", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"description": "proxy http requests, for Fastify", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"lint:typescript": "standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts", | ||
"typescript": "tsc --project ./test/types/tsconfig.json" | ||
"typescript": "tsd" | ||
}, | ||
@@ -28,9 +28,9 @@ "repository": { | ||
"devDependencies": { | ||
"@types/node": "^13.1.0", | ||
"@typescript-eslint/parser": "^2.0.0", | ||
"@types/node": "^14.0.13", | ||
"@typescript-eslint/parser": "^3.3.0", | ||
"eslint-plugin-typescript": "^0.14.0", | ||
"express": "^4.16.4", | ||
"express-http-proxy": "^1.5.0", | ||
"fastify": "^2.0.0", | ||
"got": "^10.6.0", | ||
"fastify": "^3.0.0-alpha.1", | ||
"got": "^11.3.0", | ||
"http-errors": "^1.7.1", | ||
@@ -40,13 +40,17 @@ "http-proxy": "^1.17.0", | ||
"pre-commit": "^1.2.2", | ||
"simple-get": "^3.0.3", | ||
"simple-get": "^4.0.0", | ||
"snazzy": "^8.0.0", | ||
"standard": "^14.0.2", | ||
"tap": "^14.0.0", | ||
"tsd": "^0.11.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"dependencies": { | ||
"fastify-reply-from": "^2.0.0", | ||
"fastify-websocket": "^1.1.2", | ||
"ws": "^7.2.5" | ||
"ws": "^7.2.5", | ||
"fastify-reply-from": "^3.1.0" | ||
}, | ||
"tsd": { | ||
"directory": "test" | ||
} | ||
} |
# fastify-http-proxy | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-http-proxy.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/fastify/fastify-http-proxy.svg?branch=master)](https://travis-ci.org/fastify/fastify-http-proxy) | ||
@@ -6,0 +4,0 @@ |
@@ -175,3 +175,15 @@ 'use strict' | ||
async preHandler (request, reply) { | ||
t.deepEqual(reply.context.config, { foo: 'bar', url: '/*' }) | ||
t.deepEqual(reply.context.config, { | ||
foo: 'bar', | ||
url: '/*', | ||
// GET is not there because of the nonWsMethods. | ||
method: [ | ||
'DELETE', | ||
'HEAD', | ||
'PATCH', | ||
'POST', | ||
'PUT', | ||
'OPTIONS' | ||
] | ||
}) | ||
throw new Unauthorized() | ||
@@ -178,0 +190,0 @@ } |
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
24776
17
570
157
+ Addeddepd@1.1.2(transitive)
+ Addedfastify-plugin@3.0.1(transitive)
+ Addedfastify-reply-from@3.5.0(transitive)
+ Addedhttp-errors@1.8.1(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedundici@2.2.1(transitive)
- Removedfastify-reply-from@2.2.0(transitive)
- Removedfastq@1.17.1(transitive)
- Removedhttp-parser-js@0.5.8(transitive)
- Removedlistenercount@1.0.1(transitive)
- Removedprocess-nextick-args@1.0.7(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedretimer@2.0.0(transitive)
- Removedreusify@1.0.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedsyncthrough@0.5.0(transitive)
- Removedundici@0.5.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedfastify-reply-from@^3.1.0