mirror of
https://gh-proxy.org/https://github.com/klinsmaya/open-connector.git
synced 2026-11-08 01:16:52 +08:00
24 lines
759 B
TypeScript
24 lines
759 B
TypeScript
// GitHub REST API docs: https://docs.github.com/en/rest
|
|
|
|
import { adminHeaders, fetchJson, runtimeHeaders } from "./client.ts";
|
|
|
|
const token = process.env.GITHUB_TOKEN;
|
|
if (!token) {
|
|
console.log("Set GITHUB_TOKEN to run this example.");
|
|
process.exit(0);
|
|
}
|
|
|
|
await fetchJson("http://localhost:3000/api/connections/github", {
|
|
method: "PUT",
|
|
headers: adminHeaders({ "content-type": "application/json" }),
|
|
body: JSON.stringify({ authType: "api_key", values: { apiKey: token } }),
|
|
});
|
|
|
|
const result = await fetchJson("http://localhost:3000/v1/actions/github.get_current_user", {
|
|
method: "POST",
|
|
headers: runtimeHeaders({ "content-type": "application/json" }),
|
|
body: JSON.stringify({ input: {} }),
|
|
});
|
|
|
|
console.log(JSON.stringify(result, null, 2));
|