You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

express-webhook

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-webhook

A HTTP/HTTPS endpoints(hooks) midware for express.

0.0.2
latest
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

express-webhook

A webhook in web development is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. —— wikipedia

For me, webhook can be a simple way to implement a auto deployment environment for my private site.

In my case, my private site is written in vue, and build with webpack. Every time I push my code to git server, I need to pull from my server, and it's boring enough.

Then I find the conception of webhook and I want to try it.

Usage
npm install express-webhook --save
var express = require('express');
...
var app = new express();
...

var webhook = require('express-webhook');

app.use('hooks', webhook({
    hooks: {
        '/repo1': 'echo hello!'
    }
}))
  • You need a repo on a git server which is support webhook(like GitHub, Gogs...)
  • Set the webhook event url to your path(like http://your.site/hooks/repo1), and set the event you want to hook(usually push).
  • It's good to write a shell file if you need to run complicate commands.
  • Write the command you are 'hooking' into config argument.
Config
as object or null:
  • hooks: defines hooks rules.
  • goodResultHandler: callback when command is executed properly. Default returns 200.
  • badResultHandler: callback when command is executed not properly. Default returns 400 and prints the logs.
  • notFoundHandler: callback when hook is not found. Default returns 404.
as string:

To use default config defined by others. Not prepared yet.

app.use('hooks', webhook('gogs', {...}))

FAQs

Package last updated on 20 Dec 2016

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