hukk
v1.3.0
Published
Portable webhook for NodeJS micro-service
Downloads
17
Readme
hukk
Portable webhook utilities for NodeJS micro-service
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"}}
})