Skip to main content

HTTP Push Adapter

HttpStorageAdapter POSTs batches to your ingest endpoint. Pairs well with the ingest server.

Basic usage​

import { HttpStorageAdapter } from '@drakkar.software/sunglasses-storage-http';

new HttpStorageAdapter({
endpoint: 'https://ingest.example.com/batch',
});

Payload shape​

{
"batch": [ /* SunglassesEvent[] */ ],
"sentAt": "2026-06-26T12:00:00.000Z"
}

Configuration​

OptionDefaultDescription
endpointrequiredPOST URL
headers{}Extra request headers
maxRetries3Retry attempts for retriable failures
retryBaseDelayMs1000Initial backoff delay
retryMaxDelayMs30000Maximum backoff delay
timeout10000Request timeout (ms)

Retry policy​

  • 2xx — success
  • 4xx (except 429) — non-retriable; batch discarded with warning
  • 5xx, 429, network errors, timeout — retry with exponential backoff

Batch size is controlled by maxBatchSize in SunglassesCore.create(), not by the adapter.

Local development​

new HttpStorageAdapter({ endpoint: 'http://localhost:8787/batch' })

See Ingest server for the reference server implementation.