-
Notifications
You must be signed in to change notification settings - Fork 71
fix: remove got as a dependency, replace with fetch #6468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ad2073f
to
b98179c
Compare
This pull request adds or modifies JavaScript ( |
6fd4191
to
ca4fceb
Compare
This pull request adds or modifies JavaScript ( |
1 similar comment
This pull request adds or modifies JavaScript ( |
@@ -4,7 +4,7 @@ import { promisify } from 'util' | |||
|
|||
import getStream from 'get-stream' | |||
|
|||
type Handler = { path: string; response: unknown; status?: number } | |||
type Handler = { path: string; response?: object; status?: number; wait?: number } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait
is already used in the test suite and in this file, it just wasn't listed in these types
@@ -70,8 +70,8 @@ const requestHandler = async (req: IncomingMessage, res: ServerResponse, request | |||
res.end(responseBody) | |||
} | |||
|
|||
const getHandler = function (handlers, url) { | |||
const handler = handlers.find(({ path }) => url === path || url.startsWith(`${path}?`)) | |||
const getHandler = function (handlers: Handler[], url?: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types taken from usage on line 48 in this file
@@ -91,7 +90,13 @@ const fetchPluginsList = async function ({ | |||
pluginsListUrl: string | |||
}): Promise<PluginListEntry[]> { | |||
try { | |||
const { body } = await got(pluginsListUrl, { responseType: 'json', timeout: { request: PLUGINS_LIST_TIMEOUT } }) | |||
const response = await fetch(pluginsListUrl, { signal: AbortSignal.timeout(PLUGINS_LIST_TIMEOUT) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got's responseType: 'json'
also sets accept header to application/json
( https://github.com/sindresorhus/got/blob/a359bd385129d2adbc765b52dfbbadac5f54a825/source/core/index.ts#L636-L638 ) so for full 1 to 1 migration that could be added, tho doesn't seem like needed so this can be skipped
ca4fceb
to
8ae7eb7
Compare
This pull request adds or modifies JavaScript ( |
Summary
Replace usage of
got
with nativefetch
calls insteadMakes more packages dev only, thus shrinking the overall package size.
For us to review and ship your PR efficiently, please perform the following steps:
we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
something that`s on fire 🔥 (e.g. incident related), you can skip this step.
your code follows our style guide and passes our tests.
A picture of a cute animal (not mandatory, but encouraged)