Skip to content

Commit a78835a

Browse files
authored
improve typings for replyOptions (#127)
1 parent a428241 commit a78835a

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

index.d.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
/// <reference types="node" />
22

3-
import {
4-
FastifyPlugin,
5-
preHandlerHookHandler
6-
} from "fastify";
3+
import { FastifyPlugin, preHandlerHookHandler } from "fastify";
74

85
import {
9-
FastifyReplyFromOptions
10-
} from "fastify-reply-from"
6+
FastifyReplyFromOptions,
7+
FastifyReplyFromHooks,
8+
} from "fastify-reply-from";
119

12-
import {
13-
ClientOptions,
14-
ServerOptions
15-
} from "ws"
10+
import { ClientOptions, ServerOptions } from "ws";
1611

1712
export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {
1813
upstream: string;
@@ -22,10 +17,10 @@ export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {
2217
preHandler?: preHandlerHookHandler;
2318
beforeHandler?: preHandlerHookHandler;
2419
config?: Object;
25-
replyOptions?: Object;
26-
websocket?: boolean
27-
wsClientOptions?: ClientOptions
28-
wsServerOptions?: ServerOptions
20+
replyOptions?: FastifyReplyFromHooks;
21+
websocket?: boolean;
22+
wsClientOptions?: ClientOptions;
23+
wsServerOptions?: ServerOptions;
2924
}
3025

3126
declare const fastifyHttpProxy: FastifyPlugin<FastifyHttpProxyOptions>;

test/index.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.register(fastifyHttpProxy, {
1414
rewritePrefix: "/u",
1515
http2: false,
1616
config: { key: 1 },
17-
replyOptions: { opt: "a" },
17+
replyOptions: { contentType: "application/json" },
1818
preHandler: (request, reply) => {
1919
expectType<RawRequestDefaultExpression>(request.raw);
2020
expectType<RawReplyDefaultExpression>(reply.raw);

0 commit comments

Comments
 (0)