Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gitlab-hook-handler

deju26MIT1.0.2

gitlab hook handler, koa middleware

gitlab, gitlab webhook, gitlab hook handler

readme

Install

yarn add gitlab-hook-handler

// or

npm i gitlab-hook-handler

Usage with Koa

import Koa from 'koa';
import createHandler from 'gitlab-hook-handler';

const app = new Koa();

const handler = createHandler({
    path: '/gitlab-webhook',
    secret: 'xxx'  // optional
});

// or multiple hooks
const handler = createHandler([
    {
        path: '/hook1',
        secret: 'xxx' // optional
    },
    {
        path: '/hook2',
        secret: 'xxx'  // optional
    }
])


// you can listen on merge_request, note, push, tag_push ...
handler.on('merge_request', function (event) {
    const { eventName, payload, pathname, host, url, protocol } = event;

    // do something
});

handler.on('*', function (event) {
    const { eventName, payload, pathname, host, url, protocol } = event;

    // do something
})