Skip to content
/ hukk Public

Portable webhook utilities for NodeJS micro-service

License

Notifications You must be signed in to change notification settings

nampdn/hukk

Repository files navigation

hukk

Portable webhook utilities for NodeJS micro-service

npm version Build Status FOSSA Status

Installation

yarn add hukk

Usage

Create webhook server:

import hukk from 'hukk'

// Register new hook object
hukk.register({
  endpoint: '/webhook',
  handle: (data) => {
    console.log(data)
  }
}) 

hukk.listen(3000, () => {
  console.log('Hook server listening on port 3000')
})

Send hook to another server

import {hukkup} from 'hukk'

const data = {bar: 'boo'}
hukkup({hostname: 'localhost', port: 3000, endpoint: '/webhook', data}, (err, data) => {
  if (err) {
    console.error(err)
  }
  console.log('Response: ', data) // {"body": {"bar": "boo"}}
})

License

FOSSA Status