20 lines
541 B
TypeScript
20 lines
541 B
TypeScript
import { Gitlab } from "../../types/gitlab";
|
|
|
|
export const gitlabReqWarp = async <T = any>(
|
|
func: Function,
|
|
default_value: any
|
|
): Promise<T> => {
|
|
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;
|
|
}
|
|
};
|
|
|
|
export const GITLAB_BASE_URL = "https://git.n.xiaomi.com/api/v4";
|
|
|
|
export const GITLAB_AUTH_HEADER = { "PRIVATE-TOKEN": "Zd1UASPcMwVox5tNS6ep" };
|