Neo's Playing Morpheus

    gitlab-webhook-events
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.7 • Public • Published

    gitlab-webhook-events

    Gitlab Webhooks handler based on Node.js. Support multiple handlers.

    Language

    Instructions

    If you want to know the settings of Gitlab webhooks, please see: gitlab webhooks.

    Installation

    npm install gitlab-webhook-events --save

    Usage

    var http = require('http')
    var createHandler = require('gitlab-webhook-events')
    var handler = createHandler([ // multiple handlers
      { path: '/webhook1', secret: 'secret1' },
      { path: '/webhook2', secret: 'secret2' }
    ])
    // var handler = createHandler({ path: '/webhook1', secret: 'secret1' }) // single handler
    
    http.createServer(function (req, res) {
      handler(req, res, function (err) {
        res.statusCode = 404
        res.end('no such location')
      })
    }).listen(7777)
    
    handler.on('error', function (err) {
      console.error('Error:', err.message)
    })
    
    handler.on('push', function (event) {
      console.log(
        'Received a push event for %s to %s',
        event.payload.repository.name,
        event.payload.ref
      )
      switch (event.path) {
        case '/webhook1':
          // do sth about webhook1
          break
        case '/webhook2':
          // do sth about webhook2
          break
        default:
          // do sth else or nothing
          break
      }
    })

    Install

    npm i gitlab-webhook-events

    DownloadsWeekly Downloads

    12

    Version

    1.0.7

    License

    MIT

    Unpacked Size

    17.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • ccckblaze