gitlab-event-types
v2.1.0
Published
gitlab webhook event types
Downloads
3,433
Readme
GitLab Event Types
TypeScript definitions for GitLab Webhook Event.
Install
# Use npm
npm install -D gitlab-event-types
# Use yarn
yarn add -D gitlab-event-types
# Use pnpm
pnpm add -D gitlab-event-types
Usages
import type { WebhookEvents, PushEvent } from "gitlab-event-types";
const isPushEvent = (event: WebhookEvents): event is PushEvent =>
"object_kind" in event && event.object_kind === "push";
const hookHandler = async (event: WebhookEvents) => {
if (isPushEvent(event)) {
console.log(event.commits);
}
};
Or
import type * as GitlabEventTypes from "gitlab-event-types";
const pushEventHandler = async (event: GitlabEventTypes.PushEvent) => {
console.log(event.object_kind);
};
Definitions
export type WebhookEvents =
| PushEvent
| TagPushEvent
| IssueEvent
| NoteEvent
| MergeRequestEvent
| WikiPageEvent
| PipelineEvent
| BuildEvent
| DeploymentEvent
| GroupMemberEvent
| SubgroupEvent
| FeatureFlagEvent
| ReleaseEvent;
Credits
Thanks to excaliburhan/node-gitlab-webhook(MIT License).
License
MIT