Files
shockbot/utils/gitea.ts
T

24 lines
735 B
TypeScript

import { Gitea } from "@go-gitea/sdk.js";
import type { GiteaEndpoints } from "@go-gitea/sdk.js";
export { Gitea };
export type { GiteaEndpoints };
// The SDK's ChangedFile type omits `patch`. Gitea does return it; cast to this when needed.
export interface ChangedFileWithPatch {
filename?: string;
status?: string;
additions?: number;
deletions?: number;
changes?: number;
patch?: string;
[key: string]: unknown;
}
export function createGiteaClient(): Gitea {
const baseUrl = (process.env.GITEA_URL ?? "https://git.shockvpn.com").replace(/\/$/, "");
const token = process.env.BOT_TOKEN;
if (!token) throw new Error("BOT_TOKEN environment variable is required");
return new Gitea({ baseUrl, auth: token });
}