
@octokit/rest
मूल रूप से GitHub का मूल विकास नहीं है, और github का एक अनुकूलन है - उपयोगकर्ता @bkeepers से 2017 का सबसे लोकप्रिय पैकेज । इस पोस्ट में हम GitHub REST API के@octokit/rest
लिए आधिकारिक जावास्क्रिप्ट SDK के बारे में बात करेंगे ।
ग्रेगर (लेख के लेखक) ऑक्टोकिट जावास्क्रिप्ट डेवलपर हैं। वह एक अनुभवी ओपन सोर्स डेवलपर है, जो टास्क ऑटोमेशन के लिए एक विशेष प्यास और सभी प्रकार और व्यवसायों के योगदानकर्ताओं के लिए प्रवेश सीमा को कम करता है। Octokit के अलावा, ग्रेगर पर काम कर रहा है Probot , काटने का निशान, और अर्थ रिलीज । अपने खाली समय में, वह अपने तीनों Nico, Ada और Kiana की देखभाल करता है। DEV समुदाय और ट्विटर पर अधिक ग्रेगर सामग्री पाई जा सकती है ।
विरासत
@octokit/rest
, github
Node. 2010 . Node v0.1, package.json , npm .
2017 GitHub , github
GitHub API JavaScript SDK Node.js. 2017 . 16 , JavaScript , JSON TypeScript/Flow.
➜ rest.js git:(50720c8) wc -l lib/*
120 lib/error.js
3246 lib/index.d.ts
905 lib/index.js
3232 lib/index.js.flow
17 lib/promise.js
7995 lib/routes.json
143 lib/util.js
15658 total
. routes.json 8 , REST API GitHub. , / .
, (octokit/routes) REST API GitHub JSON. routes.json. , @octokit/rest
PR routes.json, . , routes.json REST API GitHub 10 275 . TypeScript 26 700 .
API , : .
. : "decomposability", "", . " ", " " "".
JavaScript Octokit JavaScript, . , . , , REST API, ( ""), . , .
, 2018 :

:
,
➜ rest.js git:(f7c9f86) wc -l index.* lib/**/*.{js,json}
31 index.js
3474 index.d.ts
3441 index.js.flow
101 lib/endpoint/ # 4 files
162 lib/request/ # 3 files
83 lib/plugins/authentication/ # 3 files
130 lib/plugins/endpoint-methods/ # 4 files
130 lib/plugins/pagination/ # 11 files
58 lib/parse-client-options.js
10628 lib/routes.json
18238 total
:
2018 , , v16 API . , .
:
,
➜ rest.js git:(01763bf) wc -l index.* plugins/**/*.{js,json} lib/**/*.js
14 index.js
26714 index.d.ts
110 lib/ # 6 files
86 plugins/authentication/ # 3 files
77 plugins/pagination/ # 3 files
39 plugins/register-endpoints/ # 3 files
108 plugins/validate/ # 2 files
10275 plugins/rest-api-endpoints/routes.json
37423 total
@octokit/core
— Octokit JavaScript, @octokit/rest
Octokit. @octokit/rest
. @octokit/rest
, .
@octokit/core
legacy , . — README @octokit/auth
. GitHub, (eng).
@octokit/core
lib/* plugins/authentication/*
. , :
validate
TypeScript . . , octokit.checks.create()
:
{
checks: {
create: {
headers: { accept: "application/vnd.github.antiope-preview+json" },
method: "POST",
params: {
actions: { type: "object[]" },
"actions[].description": { required: true, type: "string" },
"actions[].identifier": { required: true, type: "string" },
"actions[].label": { required: true, type: "string" },
completed_at: { type: "string" },
conclusion: {
enum: [
"success",
"failure",
"neutral",
"cancelled",
"timed_out",
"action_required"
],
type: "string"
},
details_url: { type: "string" },
external_id: { type: "string" },
head_sha: { required: true, type: "string" },
name: { required: true, type: "string" },
output: { type: "object" },
"output.annotations": { type: "object[]" },
"output.annotations[].annotation_level": {
enum: ["notice", "warning", "failure"],
required: true,
type: "string"
},
"output.annotations[].end_column": { type: "integer" },
"output.annotations[].end_line": { required: true, type: "integer" },
"output.annotations[].message": { required: true, type: "string" },
"output.annotations[].path": { required: true, type: "string" },
"output.annotations[].raw_details": { type: "string" },
"output.annotations[].start_column": { type: "integer" },
"output.annotations[].start_line": { required: true, type: "integer" },
"output.annotations[].title": { type: "string" },
"output.images": { type: "object[]" },
"output.images[].alt": { required: true, type: "string" },
"output.images[].caption": { type: "string" },
"output.images[].image_url": { required: true, type: "string" },
"output.summary": { required: true, type: "string" },
"output.text": { type: "string" },
"output.title": { required: true, type: "string" },
owner: { required: true, type: "string" },
repo: { required: true, type: "string" },
started_at: { type: "string" },
status: { enum: ["queued", "in_progress", "completed"], type: "string" }
},
url: "/repos/:owner/:repo/check-runs"
}
}
}
v17, :
{
checks: {
create: [
"POST /repos/{owner}/{repo}/check-runs",
{ mediaType: { previews: ["antiope"] } },
];
}
}
, 10 :
import { Octokit as Core } from "@octokit/core";
import { requestLog } from "@octokit/plugin-request-log";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
import { VERSION } from "./version";
export const Octokit = Core.plugin([
requestLog,
paginateRest,
restEndpointMethods,
]).defaults({ userAgent: `octokit-rest.js/${VERSION}` });
v16 v17, — .
2017 , . , JavaScript Octokit SDK SDK , octokit/fixtures
— , http .
, @octokit/rest
, 100% . , 100% .
. : ,
v17 10 , v16, API. , , v17, @octokit/rest
. , @octokit/core
@octokit/request
. smoke- @octokit/fixtures
.
@octokit/rest
REST API GitHub, 17 , JavaScript, API @octokit/rest
, , . GraphQL, @octokit/core
.
अंत में, मैं फेबियन जैकब्स , माइक डी बोअर और जो गैलो को धन्यवाद कहना चाहूंगा , जिन्होंने github
इसे चालू करने से पहले मॉड्यूल बनाया और बनाए रखा @octokit/rest
।