Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

orta/github-webhook-event-types

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

This is now fully deprecated by @octokit/webhooks which has more folks keeping it up to date, and the same webhook types. Use that instead.

github-webhook-event-types

Converts the GitHub events on this page: https://developer.github.com/v3/activity/events/types/

Into TypeScript type interfaces, so you can use them anywhere.

Why would I use this?

If you're writing Dangerfiles for Peril, you'll want some safety in the types for event JSON metadata coming from GitHub. This gives you that.

How do I use this?

yarn add github-webhook-event-types 

Then in your app:

import {danger} from "danger"
import {Issues} from "github-webhook-event-types"

const issue = danger.github as any as Issues
const issueBody = issue.bdy
//                       ^---- tsc compiler err 

as any as Issues?

Yeah, weird code right? Well in the case above we're taking a known type and saying "be something else". First you tell the compiler "you can be anything", then you tell it "you are an Issue".

Otherwise you will probably be able to say as Issue from your typical JSON request.

How do I work on this?

You need Google Chrome Canary installed first.

git clone https://github.com/orta/github-webhook-event-types.git
cd github-webhook-event-types
yarn install

# Open VS Code with `code .`

# Run the script to generate them
yarn ts-node scripts/generate_types.ts

# Run this to validate your changes
yarn tsc

What is this?

It uses a headless google chrome to download the events page and pull out each example JSON and their name. It's a bit messy, but it's a messy job. It's really just one script, so you can read that instead. It's about 100 LOC.

About

TypeScript type definitions for GitHub's events

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published