外观
GitHubClient
约 1473 字大约 5 分钟
2025-08-01
@candriajs/git-neko-kit / GitHubClient
类: GitHubClient
定义于: models/platform/github/client.ts:66
GitHub API 基础服务类,提供与GitHub API交互的核心功能
此类作为GitHub API功能的入口点,封装了以下核心能力:
- JWT令牌生成与管理
- 请求代理配置
- 基础HTTP请求方法(GET/POST/PATCH/DELETE/PUT)
- 应用认证管理
- 模块化服务(App/Auth/Commit/Repo/User/WebHook)
示例
const base = new GitHubClient({
APP_ID: 12345,
Private_Key: '-----BEGIN PRIVATE KEY-----...',
Client_ID: 'Iv1.1234567890abcdef',
Client_Secret: 'abcdef1234567890abcdef1234567890abcdef12',
WebHook_Secret: 'webhook_secret'
});继承于
构造函数
构造函数
new GitHubClient(
options):GitHubClient
定义于: models/platform/github/client.ts:90
参数
options
返回
GitHubClient
属性
api_url
api_url:
string
定义于: models/platform/github/client.ts:79
app
app:
App
定义于: models/platform/github/client.ts:67
auth
auth:
Auth
定义于: models/platform/github/client.ts:68
base_url
base_url:
string
定义于: models/platform/github/client.ts:78
Client_ID?
readonlyoptionalClient_ID:null|string
定义于: models/platform/github/client.ts:83
Client_Secret?
readonlyoptionalClient_Secret:null|string
定义于: models/platform/github/client.ts:84
commit
commit:
Commit
定义于: models/platform/github/client.ts:69
format
readonlyformat:boolean
定义于: models/platform/github/client.ts:86
issue
issue:
Issue
定义于: models/platform/github/client.ts:73
jwtToken
jwtToken:
string
定义于: models/platform/github/client.ts:80
org
org:
Org
定义于: models/platform/github/client.ts:74
Private_Key?
readonlyoptionalPrivate_Key:null|string
定义于: models/platform/github/client.ts:82
pull_request
pull_request:
Pull_Request
定义于: models/platform/github/client.ts:75
repo
repo:
Repo
定义于: models/platform/github/client.ts:70
search
search:
Search
定义于: models/platform/github/client.ts:77
user
user:
User
定义于: models/platform/github/client.ts:71
userToken?
optionaluserToken:null|string
定义于: models/platform/github/client.ts:81
webhook
webhook:
WebHook
定义于: models/platform/github/client.ts:72
WebHook_Secret?
readonlyoptionalWebHook_Secret:null|string
定义于: models/platform/github/client.ts:85
workflow
workflow:
Workflow
定义于: models/platform/github/client.ts:76
访问器
is_app_client
Getter 签名
get is_app_client():
boolean
定义于: models/platform/github/client.ts:130
是否是App客户端
示例
const isAppClient = await client.is_app_client
-> true返回
boolean
是否是App客户端
type
Getter 签名
get type():
GitType
定义于: models/platform/github/client.ts:117
获取Git平台类型
示例
const type = await client.type
-> 'github'返回
Git平台类型,如: github,gitee
方法
delete()
delete(
path,params,data?,customHeaders?):Promise<ApiResponseType<any>>
定义于: models/platform/github/client.ts:602
Github DELETE 请求方法
参数
path
string
请求路径
params
URL查询参数
null | Record<string, string>
data?
any
请求体数据
customHeaders?
Record<string, string>
请求头,选项
返回
Promise<ApiResponseType<any>>
请求结果
get()
get(
path,parms?,customHeaders?):Promise<ApiResponseType<any>>
定义于: models/platform/github/client.ts:455
Github GET 请求方法
参数
path
string
请求路径
parms?
any
请求参数
customHeaders?
Record<string, string>
请求头,选项
返回
Promise<ApiResponseType<any>>
请求结果
get_app()
get_app():
Promise<App>
定义于: models/platform/github/client.ts:177
获取App实例
返回
Promise<App>
App实例
示例
const app = await GitHubClient.get_app()get_auth()
get_auth():
Promise<Auth>
定义于: models/platform/github/client.ts:191
获取Auth实例
返回
Promise<Auth>
Auth实例
示例
const auth = await GitHubClient.get_auth()get_commit()
get_commit():
Promise<Commit>
定义于: models/platform/github/client.ts:205
获取Commit实例
返回
Promise<Commit>
Commit实例
示例
const commit = await GitHubClient.get_commit()get_issue()
get_issue():
Promise<Issue>
定义于: models/platform/github/client.ts:219
获取Issue实例
返回
Promise<Issue>
Issue实例
示例
const issue = await GitHubClient.get_issue()get_org()
get_org():
Promise<Org>
定义于: models/platform/github/client.ts:261
获取Org实例
返回
Promise<Org>
Org实例
示例
const org = await GitHubClient.get_org()get_pull_request()
get_pull_request():
Promise<Pull_Request>
定义于: models/platform/github/client.ts:289
获取Pull_request实例
返回
Promise<Pull_Request>
Pull_request实例
示例
const pull_request = await GitHubClient.get_pull_request()get_repo()
get_repo():
Promise<Repo>
定义于: models/platform/github/client.ts:233
获取Repo实例
返回
Promise<Repo>
Repo实例
示例
const repo = await GitHubClient.get_repo()get_search()
get_search():
Promise<Search>
定义于: models/platform/github/client.ts:317
获取Search实例
返回
Promise<Search>
Search实例
示例
const search = await GitHubClient.get_search()get_user()
get_user():
Promise<User>
定义于: models/platform/github/client.ts:247
获取User实例
返回
Promise<User>
User实例
示例
const user = await GitHubClient.get_user()get_webhook()
get_webhook():
Promise<WebHook>
定义于: models/platform/github/client.ts:275
获取WebHook实例
返回
Promise<WebHook>
WebHook实例
示例
const webhook = await GitHubClient.get_webhook()get_workflow()
get_workflow():
Promise<Workflow>
定义于: models/platform/github/client.ts:303
获取Workflow实例
返回
Promise<Workflow>
Workflow实例
示例
const workflow = await GitHubClient.get_workflow()patch()
patch(
path,params,data,customHeaders?):Promise<ApiResponseType<any>>
定义于: models/platform/github/client.ts:528
Github PATCH 请求方法
参数
path
string
请求路径
params
URL查询参数
null | Record<string, string>
data
any
请求数据
customHeaders?
Record<string, string>
请求头,选项
返回
Promise<ApiResponseType<any>>
请求结果
post()
post(
path,data,customHeaders?):Promise<ApiResponseType<any>>
定义于: models/platform/github/client.ts:491
Github POST 请求方法
参数
path
string
请求路径
data
any
请求数据
customHeaders?
Record<string, string>
请求头,选项
返回
Promise<ApiResponseType<any>>
请求结果
put()
put(
path,data,customHeaders?):Promise<ApiResponseType<any>>
定义于: models/platform/github/client.ts:565
Github PUT 请求方法
参数
path
string
请求路径
data
any
请求数据
customHeaders?
Record<string, string>
请求头,选项
返回
Promise<ApiResponseType<any>>
请求结果
setProxy()
setProxy(
proxy):void
定义于: models/platform/github/client.ts:343
设置请求代理
参数
proxy
代理参数
返回
void
示例
setProxy({
type: 'http',
address: 'http://127.0.0.1:7890'
})setRequestConfig()
protectedsetRequestConfig(config):void
定义于: models/platform/github/client.ts:428
设置当前请求的配置
- 仅在父类与子类中方法中可访问
参数
config
配置对象,包含以下属性:
- url: 请求的URL
- token: 认证令牌
- tokenType: 认证令牌类型,默认为 'Bearer'
返回
void
setToken()
setToken(
token):void
定义于: models/platform/github/client.ts:390
设置 token 传入的 token 必须以 ghu_ 或 ghp_ 或 ghs_ 开头,否则会抛出错误
参数
token
string
传入的 token
返回
void
示例
setToken('ghu_xxxx')