{"id":18332,"library":"express-github-webhook","title":"express-github-webhook","description":"A lightweight Express middleware for handling GitHub Webhooks, version 1.0.6. It validates webhook signatures using a secret, parses event payloads, and emits events for easy integration. Unlike alternatives like `github-webhook-handler`, this package is designed specifically for Express and requires body-parser. Release cadence is low; last update was years ago, but the package is stable for basic use cases.","status":"maintenance","version":"1.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/gisonrg/express-github-webhook","tags":["javascript","github","webhook","express","middleware"],"install":[{"cmd":"npm install express-github-webhook","lang":"bash","label":"npm"},{"cmd":"yarn add express-github-webhook","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-github-webhook","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to parse JSON request bodies before the middleware runs","package":"body-parser","optional":false}],"imports":[{"note":"This package is CJS-only; no ESM support.","wrong":"import { GithubWebHook } from 'express-github-webhook';","symbol":"GithubWebHook","correct":"const GithubWebHook = require('express-github-webhook');"},{"note":"GithubWebHook is a factory function, not a constructor. Do not use 'new'.","wrong":"const webhookHandler = new GithubWebHook();","symbol":"webhookHandler","correct":"const webhookHandler = GithubWebHook({ secret: 'mysecret' });"},{"note":"For named events (not '*'), callback signature is (repo, data). The 'event' parameter is omitted.","wrong":"webhookHandler.on('push', function(event, repo, data) { ... });","symbol":"on","correct":"webhookHandler.on('push', function(repo, data) { ... });"}],"quickstart":{"code":"const express = require('express');\nconst bodyParser = require('body-parser');\nconst GithubWebHook = require('express-github-webhook');\n\nconst app = express();\napp.use(bodyParser.json());\n\nconst webhookHandler = GithubWebHook({ path: '/webhook', secret: process.env.GITHUB_SECRET ?? '' });\napp.use(webhookHandler);\n\nwebhookHandler.on('push', function(repo, data) {\n  console.log('Push event on repo:', repo);\n  console.log('Payload:', data);\n});\n\nwebhookHandler.on('*', function(event, repo, data) {\n  console.log(`Any event ${event} on repo ${repo}`);\n});\n\napp.listen(3000, () => console.log('Server listening on port 3000'));","lang":"javascript","description":"Sets up an Express server with body-parser and the GitHub webhook middleware, listens for push events and wildcard events."},"warnings":[{"fix":"Use require() instead of import.","message":"The package is CJS-only; it cannot be imported using ESM syntax (import). Use require() to avoid errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Call GithubWebHook(options) without new.","message":"GithubWebHook is a factory function, not a constructor. Calling new GithubWebHook() will throw an error.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the correct signature: webhookHandler.on('push', function(repo, data) { ... });","message":"Event listeners for specific events (e.g., 'push') have a different callback signature from the wildcard '*' event. For specific events, the callback is (repo, data). For '*', it is (event, repo, data).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure app.use(bodyParser.json()) is called before app.use(webhookHandler).","message":"The package requires body-parser to be used before the middleware. If body-parser is not applied, the middleware will not parse the payload.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use express.json() instead of body-parser: app.use(express.json());","message":"body-parser is deprecated in favor of express's built-in express.json() since Express 4.16.0. The package still expects body-parser.","severity":"deprecated","affected_versions":">=4.16.0"}],"env_vars":null,"search_vec":"'1.0.6':14 'ago':58 'altern':32 'basic':65 'bodi':48 'body-pars':47 'cadenc':51 'case':67 'design':41 'easi':29 'emit':26 'event':23,27 'express':2,7,44,71 'express-github-webhook':1 'github':3,11,35,69 'github-webhook-handl':34 'handl':10 'handler':37 'integr':30 'javascript':68 'last':54 'lightweight':6 'like':33 'low':53 'middlewar':8,72 'packag':39,61 'pars':22 'parser':49 'payload':24 'releas':50 'requir':46 'secret':21 'signatur':18 'specif':42 'stabl':63 'unlik':31 'updat':55 'use':19,66 'valid':16 'version':13 'webhook':4,12,17,36,70 'year':57","created_at":"2026-04-25T07:37:40.299323+00:00","updated_at":"2026-04-25T07:37:40.299323+00:00","problems":[{"fix":"Remove 'new': const webhookHandler = GithubWebHook({ secret: '...' });","cause":"Using 'new' keyword on the factory function.","error":"TypeError: GithubWebHook is not a constructor"},{"fix":"Provide a secret matching the GitHub webhook secret, or disable signature verification by not setting a secret (not recommended).","cause":"Request has a signature but no secret was provided in options.","error":"Error: secret is required to verify signature"},{"fix":"Run 'npm install body-parser' and ensure it is required before the middleware.","cause":"body-parser not installed.","error":"Cannot find module 'body-parser'"},{"fix":"Use function(repo, data) for specific events, or function(event, repo, data) for '*' only.","cause":"Using incorrect callback signature for specific events.","error":"webhookHandler.on('push', function(event, repo, data) {...}) but event is undefined"},{"fix":"Add app.use(bodyParser.json()) before app.use(webhookHandler).","cause":"body-parser not applied before the middleware, leaving req.body as undefined.","error":"SyntaxError: Unexpected token u in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/gisonrg/express-github-webhook","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/express-github-webhook","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}