Skip to content

Commit aee1213

Browse files
committed
Factor out BaseRequestOpts
... to make it easier to find the docs from methods that use it.
1 parent 53f2ad4 commit aee1213

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/http-api/fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { type TypedEventEmitter } from "../models/typed-event-emitter.ts";
2323
import { Method } from "./method.ts";
2424
import { ConnectionError, MatrixError, TokenRefreshError } from "./errors.ts";
2525
import {
26+
type BaseRequestOpts,
2627
HttpApiEvent,
2728
type HttpApiEventHandlerMap,
2829
type IHttpOpts,
@@ -263,7 +264,7 @@ export class FetchHttpApi<O extends IHttpOpts> {
263264
method: Method,
264265
url: URL | string,
265266
body?: Body,
266-
opts: Pick<IRequestOpts, "headers" | "json" | "localTimeoutMs" | "keepAlive" | "abortSignal" | "priority"> = {},
267+
opts: BaseRequestOpts = {},
267268
): Promise<ResponseType<T, O>> {
268269
const urlForLogs = this.sanitizeUrlForLogs(url);
269270
this.opts.logger?.debug(`FetchHttpApi: --> ${method} ${urlForLogs}`);

src/http-api/interface.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,8 @@ export interface IHttpOpts {
7474
logger?: Logger;
7575
}
7676

77-
export interface IRequestOpts extends Pick<RequestInit, "priority"> {
78-
/**
79-
* The alternative base url to use.
80-
* If not specified, uses this.opts.baseUrl
81-
*/
82-
baseUrl?: string;
83-
/**
84-
* The full prefix to use e.g.
85-
* "/_matrix/client/v2_alpha". If not specified, uses this.opts.prefix.
86-
*/
87-
prefix?: string;
77+
/** Options object for {@link FetchHttpApi.requestOtherUrl} */
78+
export interface BaseRequestOpts extends Pick<RequestInit, "priority"> {
8879
/**
8980
* map of additional request headers
9081
*/
@@ -97,6 +88,19 @@ export interface IRequestOpts extends Pick<RequestInit, "priority"> {
9788
localTimeoutMs?: number;
9889
keepAlive?: boolean; // defaults to false
9990
json?: boolean; // defaults to true
91+
}
92+
93+
export interface IRequestOpts extends BaseRequestOpts {
94+
/**
95+
* The alternative base url to use.
96+
* If not specified, uses this.opts.baseUrl
97+
*/
98+
baseUrl?: string;
99+
/**
100+
* The full prefix to use e.g.
101+
* "/_matrix/client/v2_alpha". If not specified, uses this.opts.prefix.
102+
*/
103+
prefix?: string;
100104

101105
// Set to true to prevent the request function from emitting a Session.logged_out event.
102106
// This is intended for use on endpoints where M_UNKNOWN_TOKEN is a valid/notable error response,

0 commit comments

Comments
 (0)