mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3
This commit is contained in:
166 files changed
+19790
-5539
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { Provider } from "./types";
|
||||
import { githubProvider } from "./github";
|
||||
import { giteaProvider } from "./gitea";
|
||||
import { customProvider } from "./custom";
|
||||
|
||||
export type { Provider } from "./types";
|
||||
export { verifySignature } from "./github/verify";
|
||||
|
||||
/**
|
||||
* Detection order matters: Gitea webhooks also send GitHub-compatible headers
|
||||
* (`X-GitHub-Event`, `X-Hub-Signature-256`, ...), so a Gitea request would
|
||||
* match the GitHub provider too. Check Gitea first — real GitHub requests
|
||||
* never send `X-Gitea-Event`. Custom requests carry none of the forge headers,
|
||||
* only `X-WebHooker-Signature`, so they are checked last.
|
||||
*/
|
||||
const providers: Provider[] = [giteaProvider, githubProvider, customProvider];
|
||||
|
||||
/**
|
||||
* Pick the webhook provider for a request based on its headers (e.g.
|
||||
* `X-GitHub-Event` / `X-Gitea-Event`). Returns null when no provider matches.
|
||||
*/
|
||||
export function detectProvider(headers: Record<string, string>): Provider | null {
|
||||
return providers.find((p) => p.matches(headers)) ?? null;
|
||||
}
|
||||
Reference in new issue
Block a user