All checks were successful
CI Monitor MIflow / build-image (push) Successful in 43s
根据最近的代码更改,修复了路径匹配失败的问题,以确保代码的正确性和稳定性。
22 lines
794 B
TypeScript
22 lines
794 B
TypeScript
import managePipelineEvent from "../../controllers/managePipelineEvent"
|
|
import netTool from "../../service/netTool"
|
|
import { Gitlab } from "../../types/gitlab"
|
|
|
|
/**
|
|
* 处理管理Gitlab事件的请求。
|
|
* @param req - 请求对象。
|
|
* @returns 响应对象。
|
|
*/
|
|
export const manageGitlabEventReq = async (req: Request) => {
|
|
const apiKey = req.headers.get("x-gitlab-token")
|
|
if (!apiKey) return netTool.badRequest("x-gitlab-token is required!")
|
|
const eventType = req.headers.get("x-gitlab-event")
|
|
// 只处理流水线钩子
|
|
if (eventType === "Pipeline Hook") {
|
|
const body = (await req.json()) as Gitlab.PipelineEvent
|
|
const params = new URLSearchParams(req.url.split("?")[1])
|
|
return managePipelineEvent.sendNotifyMsg(body, apiKey, params)
|
|
}
|
|
return netTool.ok()
|
|
}
|