-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
351a18b
commit 386f206
Showing
25 changed files
with
272 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
{ | ||
"extends": "../../.eslintrc.json" | ||
"extends": "../../.eslintrc.json", | ||
"rules": { | ||
"n/prefer-global/url": 0, | ||
"n/prefer-global/url-search-params": 0, | ||
"n/prefer-global/buffer": 0, | ||
"n/prefer-global/process": 0, | ||
"no-restricted-globals": 0, | ||
"unicorn/prefer-node-protocol": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
module.exports = require('../../.lintstagedrc.json'); | ||
module.exports = { | ||
...require('../../.lintstagedrc.json'), | ||
'src/**.ts': 'vitest related --run --config ./vitest.config.ts', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { setDefaultStrategy } from '../src/environment.js'; | ||
import { makeRequest } from '../src/strategies/undiciRequest.js'; | ||
|
||
setDefaultStrategy(makeRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { RESTOptions } from './shared.js'; | ||
|
||
let defaultStrategy: RESTOptions['makeRequest']; | ||
|
||
export function setDefaultStrategy(newStrategy: RESTOptions['makeRequest']) { | ||
defaultStrategy = newStrategy; | ||
} | ||
|
||
export function getDefaultStrategy() { | ||
return defaultStrategy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
export * from './lib/CDN.js'; | ||
export * from './lib/errors/DiscordAPIError.js'; | ||
export * from './lib/errors/HTTPError.js'; | ||
export * from './lib/errors/RateLimitError.js'; | ||
export * from './lib/RequestManager.js'; | ||
export * from './lib/REST.js'; | ||
export * from './lib/utils/constants.js'; | ||
export { calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse } from './lib/utils/utils.js'; | ||
import { shouldUseGlobalFetchAndWebSocket } from '@discordjs/util'; | ||
import { setDefaultStrategy } from './environment.js'; | ||
import { makeRequest } from './strategies/undiciRequest.js'; | ||
|
||
/** | ||
* The {@link /~https://github.com/discordjs/discord.js/blob/main/packages/rest/#readme | @discordjs/rest} version | ||
* that you are currently using. | ||
*/ | ||
// This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild | ||
export const version = '[VI]{{inject}}[/VI]' as string; | ||
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest); | ||
|
||
export * from './shared.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.