Fix dependabot errors

I explicitly had to downgrade "@octokit/plugin-retry" to "^6.0.0". Other
dependencies were upgraded.
This commit is contained in:
Andrew Eisenberg 2025-03-14 13:13:56 -07:00
parent f338ec87a3
commit 5f98c40063
1536 changed files with 52911 additions and 424849 deletions

View file

@ -3,33 +3,34 @@
> Send parameterized requests to GitHubs APIs with sensible defaults in browsers and Node
[![@latest](https://img.shields.io/npm/v/@octokit/request.svg)](https://www.npmjs.com/package/@octokit/request)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amaster)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amain)
`@octokit/request` is a request library for browsers & node that makes it easier
to interact with [GitHubs REST API](https://developer.github.com/v3/) and
[GitHubs GraphQL API](https://developer.github.com/v4/guides/forming-calls/#the-graphql-endpoint).
It uses [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) to parse
the passed options and sends the request using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
([node-fetch](https://github.com/bitinn/node-fetch) in Node).
the passed options and sends the request using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). You can pass a custom `fetch` function using the `options.request.fetch` option, see below.
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
<!-- toc -->
- [Features](#features)
- [Usage](#usage)
- [REST API example](#rest-api-example)
- [GraphQL example](#graphql-example)
- [Alternative: pass `method` & `url` as part of options](#alternative-pass-method--url-as-part-of-options)
- [Authentication](#authentication)
- [request()](#request)
- [`request.defaults()`](#requestdefaults)
- [`request.endpoint`](#requestendpoint)
- [Special cases](#special-cases)
- [The `data` parameter set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
- [LICENSE](#license)
- [request.js](#requestjs)
- [Features](#features)
- [Usage](#usage)
- [REST API example](#rest-api-example)
- [GraphQL example](#graphql-example)
- [Alternative: pass `method` \& `url` as part of options](#alternative-pass-method--url-as-part-of-options)
- [Authentication](#authentication)
- [request()](#request)
- [`request.defaults()`](#requestdefaults)
- [`request.endpoint`](#requestendpoint)
- [Special cases](#special-cases)
- [The `data` parameter set request body directly](#the-data-parameter--set-request-body-directly)
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
- [Set a custom Agent to your requests](#set-a-custom-agent-to-your-requests)
- [LICENSE](#license)
<!-- tocstop -->
@ -57,7 +58,7 @@ request("POST /repos/{owner}/{repo}/issues/{number}/labels", {
- `baseUrl`: `https://api.github.com`
- `headers.accept`: `application/vnd.github.v3+json`
- `headers.agent`: `octokit-request.js/<current version> <OS information>`, e.g. `octokit-request.js/1.2.3 Node.js/10.15.0 (macOS Mojave; x64)`
- `headers['user-agent']`: `octokit-request.js/<current version> <OS information>`, e.g. `octokit-request.js/1.2.3 Node.js/10.15.0 (macOS Mojave; x64)`
👌 Simple to test: mock requests by passing a custom fetch method.
@ -70,11 +71,11 @@ request("POST /repos/{owner}/{repo}/issues/{number}/labels", {
<tr><th>
Browsers
</th><td width=100%>
Load <code>@octokit/request</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
Load <code>@octokit/request</code> directly from <a href="https://esm.sh">esm.sh</a>
```html
<script type="module">
import { request } from "https://cdn.skypack.dev/@octokit/request";
import { request } from "https://esm.sh/@octokit/request";
</script>
```
@ -86,8 +87,7 @@ Node
Install with <code>npm install @octokit/request</code>
```js
const { request } = require("@octokit/request");
// or: import { request } from "@octokit/request";
import { request } from "@octokit/request";
```
</td></tr>
@ -164,7 +164,7 @@ const result = await requestWithAuth("GET /user");
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
```js
const { createAppAuth } = require("@octokit/auth-app");
import { createAppAuth } from "@octokit/auth-app";
const auth = createAppAuth({
appId: process.env.APP_ID,
privateKey: process.env.PRIVATE_KEY,
@ -186,7 +186,7 @@ const { data: app } = await requestWithAuth(
owner: "octocat",
repo: "hello-world",
title: "Hello from the engine room",
}
},
);
```
@ -244,6 +244,17 @@ const { data: app } = await requestWithAuth(
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code>.<br> Use <code>options.mediaType.{format,previews}</code> to request API previews and custom media types.
</td>
</tr>
<tr>
<th align=left>
<code>options.method</code>
</th>
<td>
String
</td>
<td>
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case-insensitive. <em>Defaults to <code>Get</code></em>.
</td>
</tr>
<tr>
<th align=left>
<code>options.mediaType.format</code>
@ -263,18 +274,8 @@ const { data: app } = await requestWithAuth(
Array of strings
</td>
<td>
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://developer.github.com/v3/previews/">API Previews</a>.
</td>
</tr>
<tr>
<th align=left>
<code>options.method</code>
</th>
<td>
String
</td>
<td>
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://docs.github.com/graphql/overview/schema-previews">GraphQL Schema Previews</a>.
Note that these only apply to GraphQL requests and have no effect on REST routes.
</td>
</tr>
<tr>
@ -300,17 +301,7 @@ const { data: app } = await requestWithAuth(
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The `data` parameter"</a> below.
</td>
</tr>
<tr>
<th align=left>
<code>options.request.agent</code>
</th>
<td>
<a href="https://nodejs.org/api/http.html#http_class_http_agent">http(s).Agent</a> instance
</td>
<td>
Node only. Useful for custom proxy, certificate, or dns lookup.
</td>
</tr>
<tr>
<th align=left>
<code>options.request.fetch</code>
@ -319,7 +310,7 @@ const { data: app } = await requestWithAuth(
Function
</td>
<td>
Custom replacement for <a href="https://github.com/bitinn/node-fetch">built-in fetch method</a>. Useful for testing or request hooks.
Custom replacement for <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">fetch</a>. Useful for testing or request hooks.
</td>
</tr>
<tr>
@ -330,7 +321,7 @@ const { data: app } = await requestWithAuth(
Function
</td>
<td>
Function with the signature <code>hook(request, endpointOptions)</code>, where <code>endpointOptions</code> are the parsed options as returned by <a href="https://github.com/octokit/endpoint.js#endpointmergeroute-options-or-endpointmergeoptions"><code>endpoint.merge()</code></a>, and <code>request</code> is <a href="https://github.com/octokit/request.js#request"><code>request()</code></a>. This option works great in conjuction with <a href="https://github.com/gr2m/before-after-hook">before-after-hook</a>.
Function with the signature <code>hook(request, endpointOptions)</code>, where <code>endpointOptions</code> are the parsed options as returned by <a href="https://github.com/octokit/endpoint.js#endpointmergeroute-options-or-endpointmergeoptions"><code>endpoint.merge()</code></a>, and <code>request</code> is <a href="https://github.com/octokit/request.js#request"><code>request()</code></a>. This option works great in conjunction with <a href="https://github.com/gr2m/before-after-hook">before-after-hook</a>.
</td>
</tr>
<tr>
@ -354,15 +345,15 @@ const { data: app } = await requestWithAuth(
Used for internal logging. Defaults to <a href="https://developer.mozilla.org/en-US/docs/Web/API/console"><code>console</code></a>.
</td>
</tr>
<tr>
</tr>
<th align=left>
<code>options.request.timeout</code>
<code>options.request.parseSuccessResponseBody</code>
</th>
<td>
Number
<code>boolean</code>
</td>
<td>
Node only. Request/response timeout in ms, it resets on redirect. 0 to disable (OS limit applies). <a href="#options-request-signal">options.request.signal</a> is recommended instead.
If set to <code>false</code> the returned `response` will be passed through from `fetch`. This is useful to stream response.body when downloading files from the GitHub API.
</td>
</tr>
</table>
@ -375,7 +366,7 @@ All other options except `options.request.*` will be passed depending on the `me
**Result**
`request` returns a promise and resolves with 4 keys
`request` returns a promise. If the request was successful, the promise resolves with an object containing 4 keys:
<table>
<thead>
@ -413,18 +404,21 @@ All other options except `options.request.*` will be passed depending on the `me
</tr>
</table>
If an error occurs, the `error` instance has additional properties to help with debugging
If an error occurs, the promise is rejected with an `error` object containing 3 keys to help with debugging:
- `error.status` The http response status code
- `error.request` The request options such as `method`, `url` and `data`
- `error.response` The http response object with `url`, `headers`, and `data`
If the error is due to an `AbortSignal` being used, the resulting `AbortError` is bubbled up to the caller.
## `request.defaults()`
Override or set default options. Example:
```js
const myrequest = require("@octokit/request").defaults({
import { request } from "@octokit/request";
const myrequest = request.defaults({
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
headers: {
"user-agent": "myApp/1.2.3",
@ -542,10 +536,44 @@ request(
authorization: `token 0000000000000000000000000000000000000001`,
},
data: "Hello, world!",
}
},
);
```
### Set a custom Agent to your requests
The way to pass a custom `Agent` to requests is by creating a custom `fetch` function and pass it as `options.request.fetch`. A good example can be [undici's `fetch` implementation](https://undici.nodejs.org/#/?id=undicifetchinput-init-promise).
Example ([See example in CodeSandbox](https://codesandbox.io/p/sandbox/nifty-stitch-wdlwlf))
```js
import { request } from "@octokit/request";
import { fetch as undiciFetch, Agent } from "undici";
/** @type {typeof import("undici").fetch} */
const myFetch = (url, options) => {
return undiciFetch(url, {
...options,
dispatcher: new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
}),
});
};
const { data } = await request("GET /users/{username}", {
username: "octocat",
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
options: {
request: {
fetch: myFetch,
},
},
});
```
## LICENSE
[MIT](LICENSE)