Socket
Socket
Sign inDemoInstall

@octokit/webhooks-types

Package Overview
Dependencies
Maintainers
4
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/webhooks-types

Generated TypeScript definitions based on community contributed JSON Schemas


Version published
Weekly downloads
801K
increased by9.43%
Maintainers
4
Weekly downloads
 
Created

What is @octokit/webhooks-types?

@octokit/webhooks-types is an npm package that provides TypeScript definitions for GitHub webhook events. It helps developers to type-check their code when handling GitHub webhooks, ensuring that they are using the correct event payloads and properties.

What are @octokit/webhooks-types's main functionalities?

Type Definitions for Webhook Events

This feature provides type definitions for various GitHub webhook events, such as 'push', 'pull_request', etc. The code sample demonstrates how to handle a 'push' event with type safety.

const { WebhookEvent } = require('@octokit/webhooks-types');

/**
 * Example of handling a 'push' event
 * @param {WebhookEvent<'push'>} event - The push event payload
 */
function handlePushEvent(event) {
  console.log(`Received a push event for ${event.payload.repository.full_name}`);
  console.log(`Pushed by: ${event.payload.pusher.name}`);
}

// Example payload
const pushEventPayload = {
  payload: {
    repository: { full_name: 'octocat/Hello-World' },
    pusher: { name: 'octocat' }
  }
};

handlePushEvent(pushEventPayload);

TypeScript Support

This feature ensures that developers can use TypeScript to handle GitHub webhook events with type safety. The code sample demonstrates handling a 'pull_request' event with TypeScript.

import { WebhookEvent } from '@octokit/webhooks-types';

/**
 * Example of handling a 'pull_request' event
 * @param {WebhookEvent<'pull_request'>} event - The pull request event payload
 */
function handlePullRequestEvent(event: WebhookEvent<'pull_request'>) {
  console.log(`Received a pull request event for ${event.payload.repository.full_name}`);
  console.log(`Action: ${event.payload.action}`);
}

// Example payload
const pullRequestEventPayload = {
  payload: {
    repository: { full_name: 'octocat/Hello-World' },
    action: 'opened'
  }
};

handlePullRequestEvent(pullRequestEventPayload);

Other packages similar to @octokit/webhooks-types

FAQs

Package last updated on 11 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc