Portable webhook utilities for NodeJS micro-service
yarn add hukk
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')
})
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"}}
})