feat: no-de-no-de, now with extra buns (#9683)

BREAKING CHANGE: The REST and RequestManager classes now extend AsyncEventEmitter
from `@vladfrangu/async_event_emitter`, which aids in cross-compatibility
between Node, Deno, Bun, CF Workers, Vercel Functions, etc.

BREAKING CHANGE: DefaultUserAgentAppendix has been adapted to support multiple
different platforms (previously mentioned Deno, Bun, CF Workers, etc)

BREAKING CHANGE: the entry point for `@discordjs/rest` will now differ
in non-node-like environments (CF Workers, etc.)

Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: suneettipirneni <suneettipirneni@icloud.com>
This commit is contained in:
Vlad Frangu
2023-07-17 09:27:57 +03:00
committed by GitHub
parent 351a18bc35
commit 386f206caf
25 changed files with 272 additions and 179 deletions

View File

@@ -1,8 +1,8 @@
import { Buffer } from 'node:buffer';
import { STATUS_CODES } from 'node:http';
import { URLSearchParams } from 'node:url';
import { types } from 'node:util';
import { type RequestInit, request } from 'undici';
import type { ResponseLike } from '../index.js';
import type { ResponseLike } from '../shared.js';
export type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
@@ -30,6 +30,7 @@ export async function makeRequest(url: string, init: RequestInit): Promise<Respo
},
headers: new Headers(res.headers as Record<string, string[] | string>),
status: res.statusCode,
statusText: STATUS_CODES[res.statusCode]!,
ok: res.statusCode >= 200 && res.statusCode < 300,
};
}