Package Exports
- drumstick
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (drumstick) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
drumstick 🎼
drumstick let's you send a heartbeat to a custom endpoint in a fixed interval.
Features
- 🔁 heartbeat to a server in a fixed interval
- 🖌 at run-time customizable payload
Installation
npm install --save drumstick
Usage
🎼 Import drumstick and call start().
import drumstick from 'drumstick'
drumstick.start({
method: 'POST',
endpoint: 'http://localhost',
payload: {},
frequency: 1000,
debug: false,
})Configuration
- method: the type of HTTP request to send the server
POST | GET | HEAD | PUT | DELETE - endpoint: the endpoint drumstick should send the payload
- payload: the payload that should be sent to the endpoint (Will be stringified before sending)
- frequency: the frequency for the heartbeat in milliseconds
- debug: outputs the body of a succeeded request
Functions
There are also other functions that you can call to change the behavior of drumstick at runtime.
changePayload(payload)
Change the payload at anytime to any json object. It'll be stringified before sending to the endpoint.
changeFrequency(frequency)
Change the frequency of heartbeat.
pause()
Pauses the heartbeat.
resume()
Resumes the heartbeat after it has been paused.