import { Gitlab } from "../../types/gitlab" /** * 包装一个 GitLab 请求函数,处理错误并返回默认值。 * @template T * @param {() => Promise} func - 要执行的请求函数。 * @param {any} default_value - 请求失败时返回的默认值。 * @returns {Promise} 一个解析为请求结果或默认值的 promise。 */ export const gitlabReqWarp = async ( func: () => Promise, default_value: any ): Promise => { try { let response = {} as T & Gitlab.Error response = (await func()) as T & Gitlab.Error if (response.message === "404 Project Not Found") return default_value return response } catch { return default_value } } /** * GitLab API 的基础 URL。 * @type {string} */ export const GITLAB_BASE_URL = "https://git.n.xiaomi.com/api/v4" /** * GitLab API 的认证头。 * @type {object} */ export const GITLAB_AUTH_HEADER = { "PRIVATE-TOKEN": "Zd1UASPcMwVox5tNS6ep" }