Store HTTP requests in buffers and send them periodically
Last updated 2 years ago by mayerlevy .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install @livup/buffered-requests 
SYNC missed versions from official npm registry.

Buffered Requests


npm install @livup/buffered-requests


const bufferedRequests = require('@livup/buffered-requests');
await bufferedRequests.initialize({
	mongoAddress: 'mongodb://localhost/my_db',


async initialize({ mongoAddress, mongoOptions, processInterval, maxRequests, maxAttempts })

Initializes the module.

  • mongoAddress [String] (required): Address of mongo database
  • mongoOptions [String]: Mongo connection options
  • verbose [Boolean]: Show logs
  • processInterval [Number]: Time between requests
  • maxRequests [Number]: Max number of simultaneous requests
  • maxAttempts [Number]: Max attempts to repeat a request after an error
  • eventEmitter [EventEmitter]: Event that listens to requests success/failure


const bufferedRequests = require('@livup/buffered-requests');
await bufferedRequest.initialize({
	mongoAddress: 'mongodb://localhost/my_db',
	verbose: true,
	processInterval: 1000

async addRequest({ url, method, body, headers, json, retryOnError, successEvent, errorEvent })

Add a request to the buffer

  • url [String] (required): Request endpoint
  • method [String] (required): GET, POST, PUT or DELETE
  • body [Object]: Request data
  • headers [Object]: Request headers
  • json [Boolean]: Sets body and response to JSON and add Content-Type: application/json header
  • retryOnError [Boolean]: Keep retrying the request on error until reaching 'maxAttempts' from config.
  • successEvent [String]: Success event name
  • errorEvent [String]: Error event name


const bufferedRequests = require('@livup/buffered-requests');
	url: 'http://www.example.com',
	method: 'POST',
	body: {
		something: 'some data'
	headers: {
		'Content-Type': 'text/plain'
	successEvent: 'success_event'

async updateRequest({ _id, status, attempt })

Update a specific request

  • _id [ObjectId] (required): Request id
  • status [String] (required): queued, success or failed
  • attempt [Object]: Request attempt info, with timestamp [Date], response [String] and status [Number]


Returns all queued requests


Returns all processing requests

Current Tags

  • 1.0.2                                ...           latest (2 years ago)

3 Versions

  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Today 0
This Week 3
This Month 4
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |