Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions index.d.ts

This file was deleted.

10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function generateRewritePrefix (prefix = '', opts) {
return rewritePrefix
}

async function httpProxy (fastify, opts) {
async function fastifyHttpProxy (fastify, opts) {
if (!opts.upstream && !(opts.upstream === '' && opts.replyOptions && typeof opts.replyOptions.getUpstream === 'function')) {
throw new Error('upstream must be specified')
}
Expand Down Expand Up @@ -261,11 +261,11 @@ async function httpProxy (fastify, opts) {
}
}

httpProxy[Symbol.for('plugin-meta')] = {
fastifyHttpProxy[Symbol.for('plugin-meta')] = {
fastify: '4.x',
name: '@fastify/http-proxy'
}

module.exports = httpProxy
module.exports.default = httpProxy
module.exports.fastifyHttpProxy = httpProxy
module.exports = fastifyHttpProxy
module.exports.default = fastifyHttpProxy
module.exports.fastifyHttpProxy = fastifyHttpProxy
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "8.2.3",
"description": "proxy http requests, for Fastify",
"main": "index.js",
"types": "index.d.ts",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
Expand Down
36 changes: 36 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// <reference types='node' />

import { FastifyPluginCallback, preHandlerHookHandler } from 'fastify';

import {
FastifyReplyFromOptions,
FastifyReplyFromHooks,
} from '@fastify/reply-from';

import { ClientOptions, ServerOptions } from 'ws';

type FastifyHttpProxy = FastifyPluginCallback<fastifyHttpProxy.FastifyHttpProxyOptions>;

declare namespace fastifyHttpProxy {
export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {
upstream: string;
Copy link

@Antiavanti Antiavanti Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #15 (simple fromOpts.base = opts.upstream), why only upstream: string;?
https://github.com/fastify/fastify-reply-from/blob/main/types/index.d.ts#L109

    base?: string | string[];

([] used to instrument undici.BalancedPool) -> https://github.com/fastify/fastify-reply-from?tab=readme-ov-file#base

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open a new issue to discuss this or provide a PR to fix it.

prefix?: string;
rewritePrefix?: string;
proxyPayloads?: boolean;
preHandler?: preHandlerHookHandler;
beforeHandler?: preHandlerHookHandler;
config?: Object;
replyOptions?: FastifyReplyFromHooks;
websocket?: boolean;
wsClientOptions?: ClientOptions;
wsServerOptions?: ServerOptions;
httpMethods?: string[];
constraints?: { [name: string]: any };
}

export const fastifyHttpProxy: FastifyHttpProxy
export { fastifyHttpProxy as default }
}

declare function fastifyHttpProxy(...params: Parameters<FastifyHttpProxy>): ReturnType<FastifyHttpProxy>
export = fastifyHttpProxy
2 changes: 1 addition & 1 deletion test/types/index.test-d.ts → types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fastify, { RawReplyDefaultExpression, RawRequestDefaultExpression } from 'fastify';
import { expectError, expectType } from 'tsd';
import fastifyHttpProxy from '../..';
import fastifyHttpProxy from '..';

const app = fastify();

Expand Down