25 lines
707 B
TypeScript
25 lines
707 B
TypeScript
import { Gitlab } from "../../types/gitlab";
|
|
import netTool from "../netTool";
|
|
import { GITLAB_AUTH_HEADER, GITLAB_BASE_URL, gitlabReqWarp } from "./tools";
|
|
|
|
/**
|
|
* 获取 GitLab 项目的详细信息。
|
|
* @param project_id - 项目的 ID 或 URL-encoded 路径。
|
|
* @returns 一个解析为项目详细信息的 promise。
|
|
*/
|
|
const getDetail = async (project_id: number | string) => {
|
|
if (typeof project_id === "string")
|
|
project_id = encodeURIComponent(project_id);
|
|
const URL = `${GITLAB_BASE_URL}/projects/${project_id}`;
|
|
return gitlabReqWarp<Gitlab.ProjDetail>(
|
|
() => netTool.get(URL, {}, GITLAB_AUTH_HEADER),
|
|
null
|
|
);
|
|
};
|
|
|
|
const project = {
|
|
getDetail,
|
|
};
|
|
|
|
export default project;
|