Skip to content

Commit df0670c

Browse files
authored
refactor: update URLs (#1863)
* style: prettier * refactor: update URLs to new website: https://docs.github.com/rest/ * build(package): apply prettier to all `*.md` files in root folder
1 parent d9ca510 commit df0670c

12 files changed

+45
-41
lines changed

CODE_OF_CONDUCT.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
88

99
Examples of behavior that contributes to creating a positive environment include:
1010

11-
* Using welcoming and inclusive language
12-
* Being respectful of differing viewpoints and experiences
13-
* Gracefully accepting constructive criticism
14-
* Focusing on what is best for the community
15-
* Showing empathy towards other community members
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
1616

1717
Examples of unacceptable behavior by participants include:
1818

19-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20-
* Trolling, insulting/derogatory comments, and personal or political attacks
21-
* Public or private harassment
22-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23-
* Other conduct which could reasonably be considered inappropriate in a professional setting
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
2424

2525
## Our Responsibilities
2626

HOW_IT_WORKS.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
4. [Hooks ⑤ & ⑨](#request)
1313

1414
<a name="endpoint-options"></a>
15+
1516
## Endpoint options (① - ④)
1617

17-
`@octokit/rest` exposes a method for each [REST API endpoint](https://developer.github.com/v3/), for example `octokit.repos.listForOrg()` for [`GET /orgs/:org/repos`](https://developer.github.com/v3/repos/#list-organization-repositories). The methods are generated in [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/). The [`src/generated/endpoints.ts` file](https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/src/generated/endpoints.ts) defines the **② endpoint default options** `method`, `url`, and in some cases `mediaType` and `headers`.
18+
`@octokit/rest` exposes a method for each [REST API endpoint](https://docs.github.com/en/rest/reference/), for example `octokit.repos.listForOrg()` for [`GET /orgs/:org/repos`](https://docs.github.com/en/rest/reference/repos/#list-organization-repositories). The methods are generated in [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/). The [`src/generated/endpoints.ts` file](https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/src/generated/endpoints.ts) defines the **② endpoint default options** `method`, `url`, and in some cases `mediaType` and `headers`.
1819

1920
**② endpoint default options** are merged with **① global defaults**, which are based on [@octokit/endpoint/src/defaults.ts](https://github.com/octokit/endpoint.js/blob/master/src/defaults.ts) and the options that were passed into the `new Octokit(options)` constructor.
2021

@@ -23,7 +24,7 @@ Both are merged with **③ user options** passed into each method. Altogether th
2324
**Example**: get all public repositories of the the [@octokit](https://github.com/octokit) GitHub organization.
2425

2526
```js
26-
octokit.repos.listForOrg({ org: 'octokit', type: 'public' })
27+
octokit.repos.listForOrg({ org: "octokit", type: "public" });
2728
```
2829

2930
**④ endpoint options** will be
@@ -74,6 +75,7 @@ octokit.repos.listForOrg({ org: 'octokit', type: 'public' })
7475
</table>
7576

7677
<a name="transform"></a>
78+
7779
## Transform endpoint to request options (⑥ - ⑦)
7880

7981
**④ Endpoint options** are **⑥ transformed** into **⑦ request options** using [@octokit/endpoint](https://github.com/octokit/endpoint.js).
@@ -101,34 +103,36 @@ For example, the endpoint options shown above would result in
101103
</table>
102104

103105
<a name="request"></a>
106+
104107
## Sending a request & receiving a response ⑧ & ⑩
105108

106109
Using **⑦ request options**, a **⑧ request** is sent to the GitHub REST API. The **⑩ response** is returned to the user.
107110

108111
Requests are sent using [`@octokit/request`](https://github.com/octokit/request.js). It's using the native fetch method in the browsers and [node-fetch](https://github.com/bitinn/node-fetch) in other environments.
109112

110113
<a name="hooks"></a>
114+
111115
## Hooks ⑤ & ⑨
112116

113117
Hooks are used to inject functionality like authentication. For example, the [request log plugin](https://github.com/octokit/plugin-request-log.js) is registering a request hook in [src/index.ts](https://github.com/octokit/plugin-request-log.js/blob/e8308e36e049946a0b1813b8b25aa28d4a6c8789/src/index.ts#L9-L35). A debug message is logged before sending the request, and an info message is logged once a response is received.
114118

115119
Hooks can be registered using `octokit.hook.{before|after|error|wrap}`:
116120

117121
```js
118-
octokit.hook.before('request', async (options) => {
119-
validate(options)
120-
})
121-
octokit.hook.after('request', async (response, options) => {
122-
console.log(`${options.method} ${options.url}: ${response.status}`)
123-
})
124-
octokit.hook.error('request', async (error, options) => {
122+
octokit.hook.before("request", async (options) => {
123+
validate(options);
124+
});
125+
octokit.hook.after("request", async (response, options) => {
126+
console.log(`${options.method} ${options.url}: ${response.status}`);
127+
});
128+
octokit.hook.error("request", async (error, options) => {
125129
if (error.status === 304) {
126-
return findInCache(error.headers.etag)
130+
return findInCache(error.headers.etag);
127131
}
128132

129-
throw error
130-
})
131-
octokit.hook.wrap('request', async (request, options) => {})
133+
throw error;
134+
});
135+
octokit.hook.wrap("request", async (request, options) => {});
132136
```
133137

134138
The methods can return a Promise for asynchronous execution. `options` can be changed in the `octokit.hook.before` callback before they are **⑥ transformed**. The **⑩ response** can be changed in the `octokit.hook.after` callback before it is returned to the user. `octokit.hook.wrap` allows to do both, or replace the original request method altogether with a custom request method.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install @octokit/rest
1717
const { Octokit } = require("@octokit/rest");
1818
const octokit = new Octokit();
1919

20-
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
20+
// Compare: https://docs.github.com/en/rest/reference/repos/#list-organization-repositories
2121
octokit.repos
2222
.listForOrg({
2323
org: "octokit",

docs/src/pages/api/00_usage.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Learn more about [authentication](#authentication).
4949
auth: "secret123",
5050
```
5151
52-
Setting a user agent [is required](https://developer.github.com/v3/#user-agent-required). It defaults to `octokit/rest.js v1.2.3` where `v1.2.3` is the current version of `@octokit/rest`, but you should set it to something that identifies your app or script.
52+
Setting a user agent [is required](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required). It defaults to `octokit/rest.js v1.2.3` where `v1.2.3` is the current version of `@octokit/rest`, but you should set it to something that identifies your app or script.
5353
5454
```js
5555
userAgent: 'myApp v1.2.3',
@@ -69,7 +69,7 @@ A default time zone can be enabled by setting the `timeZone` option.
6969
timeZone: 'Europe/Amsterdam',
7070
```
7171
72-
Learn more about [using time zones with the GitHub API](https://developer.github.com/v3/#using-the-time-zone-header).
72+
Learn more about [using time zones with the GitHub API](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#timezones).
7373
7474
In order to use Octokit with GitHub Enterprise, set the `baseUrl` option.
7575
@@ -117,7 +117,7 @@ const { data: pullRequest } = await octokit.pulls.get({
117117
});
118118
```
119119
120-
Some API endpoints support alternative response formats, see [Media types](https://developer.github.com/v3/media/). For example, to [request the above pull request in a diff format](https://developer.github.com/v3/media/#diff), pass the `mediaType.format` option.
120+
Some API endpoints support alternative response formats, see [Media types](https://docs.github.com/en/rest/overview/media-types). For example, to [request the above pull request in a diff format]((https://docs.github.com/en/rest/overview/media-types/#diff), pass the `mediaType.format` option.
121121
122122
Learn more about [request formats](#request-formats).
123123
@@ -132,7 +132,7 @@ const { data: diff } = await octokit.pulls.get({
132132
});
133133
```
134134
135-
For the API endpoints that do not have a matching method, such as the [root endpoint](https://developer.github.com/v3/#root-endpoint) or legacy endpoints, you can send custom requests.
135+
For the API endpoints that do not have a matching method, such as the [root endpoint](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#root-endpoint) or legacy endpoints, you can send custom requests.
136136
137137
Learn more about [custom requests](#custom-requests).
138138

docs/src/pages/api/01_authentication.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Authentication"
33
---
44

5-
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://developer.github.com/v3/#rate-limiting).
5+
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
66

77
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). Pass in a token using `options.auth`. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The `Authorization` header will be set according to the type of token.
88

docs/src/pages/api/02_previews.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Previews"
33
---
44

5-
To enable any of [GitHub’s API Previews](https://developer.github.com/v3/previews/),
5+
To enable any of [GitHub’s API Previews](https://docs.github.com/en/rest/overview/api-previews/),
66
pass the `previews` option to the GitHub constructor
77

88
```js

docs/src/pages/api/03_request_formats.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: "Request formats & aborts"
33
---
44

5-
Some API endpoints support alternative response formats, see [Media types](https://developer.github.com/v3/media/).
5+
Some API endpoints support alternative response formats, see [Media types](https://docs.github.com/en/rest/reference/media/).
66

7-
For example, to request a [pull request as diff format](https://developer.github.com/v3/media/#diff), set the `mediaType.format` option
7+
For example, to request a [pull request as diff format](https://docs.github.com/en/rest/reference/media/#diff), set the `mediaType.format` option
88

99
```js
1010
const { data: prDiff } = await octokit.pulls.get({

docs/src/pages/api/05_pagination.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Pagination"
33
---
44

5-
All endpoint methods starting with `.list*` do not return all results at once but instead return the first 30 items by default, see also [GitHub’s REST API pagination documentation](https://developer.github.com/v3/#pagination).
5+
All endpoint methods starting with `.list*` do not return all results at once but instead return the first 30 items by default, see also [GitHub’s REST API pagination documentation](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#pagination).
66

77
To automatically receive all results across all pages, you can use the `octokit.paginate()` method:
88

@@ -20,7 +20,7 @@ octokit
2020

2121
`octokit.paginate()` accepts the same options as [`octokit.request()`](#custom-requests). You can optionally pass an additional function to map the results from each response. The map must return a new value, usually an array with mapped data.
2222

23-
**Note:** the map function is called with the `{ data, headers, status, url }` response object. The `data` property is guaranteed to be an array of the result items, even for list endpoints that respond with an object instead of an array, such as the [search endpoints](https://developer.github.com/v3/search/#example).
23+
**Note:** the map function is called with the `{ data, headers, status, url }` response object. The `data` property is guaranteed to be an array of the result items, even for list endpoints that respond with an object instead of an array, such as the [search endpoints](https://docs.github.com/en/rest/reference/search/#example).
2424

2525
```js
2626
octokit

docs/src/pages/api/09_throttling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Throttling"
44

55
When you send too many requests in too little time you will likely hit errors due to rate and/or abuse limits.
66

7-
In order to automatically throttle requests as recommended in [GitHub’s best practices for integrators](https://developer.github.com/v3/guides/best-practices-for-integrators/), we recommend you install the [`@octokit/plugin-throttling` plugin](https://github.com/octokit/plugin-throttling.js).
7+
In order to automatically throttle requests as recommended in [GitHub’s best practices for integrators](https://docs.github.com/en/rest/reference/guides/best-practices-for-integrators/), we recommend you install the [`@octokit/plugin-throttling` plugin](https://github.com/octokit/plugin-throttling.js).
88

99
The `throttle.onAbuseLimit` and `throttle.onRateLimit` options are required.
1010

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"scripts": {
5959
"build": "pika build",
6060
"coverage": "nyc report --reporter=html && open coverage/index.html",
61-
"lint": "prettier --check '{src,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' README.md package.json",
62-
"lint:fix": "prettier --write '{src,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' README.md package.json",
61+
"lint": "prettier --check '{src,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' *.md package.json",
62+
"lint:fix": "prettier --write '{src,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' *.md package.json",
6363
"start-fixtures-server": "octokit-fixtures-server",
6464
"pretest": "npm run -s lint",
6565
"test": "jest --coverage",

test/integration/deprecations-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1075,9 +1075,9 @@ describe("deprecations", () => {
10751075
* URL though: `/applications/:client_id/tokens/:access_token`. We identify this acception by looking
10761076
* for this path.
10771077
*
1078-
* 1. [Check an authorization](https://developer.github.com/v3/oauth_authorizations/#check-an-authorization)
1079-
* 2. [Reset an authorization](https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization)
1080-
* 3. [Revoke an authorization for an application](https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application)
1078+
* 1. [Check an authorization](https://docs.github.com/en/rest/reference/apps/#check-an-authorization)
1079+
* 2. [Reset an authorization](https://docs.github.com/en/rest/reference/apps/#reset-an-authorization)
1080+
* 3. [Revoke an authorization for an application](https://docs.github.com/en/rest/reference/apps/#revoke-an-authorization-for-an-application)
10811081
*/
10821082
it("OAuth client & secret to check authorization", () => {
10831083
nock("https://authentication-test-host.com", {

test/issues/1497-include-error-message-on-validation-error-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("https://github.com/octokit/rest.js/issues/1497", () => {
2929
"Only organization repositories can have users and team restrictions",
3030
],
3131
documentation_url:
32-
"https://developer.github.com/v3/repos/branches/#update-branch-protection",
32+
"https://docs.github.com/en/rest/reference/repos/#update-branch-protection",
3333
});
3434

3535
const octokit = new Octokit({

0 commit comments

Comments
 (0)