npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bedloop

v0.1.0-alpha.7

Published

TypeScript client for Bedloop API with real-time messaging and booking management

Readme

Bedloop API Client

A TypeScript client for the Bedloop API with real-time messaging and booking management capabilities.

Features

  • Authentication with automatic token management and retry logic
  • Real-time message polling from conversations
  • Booking management with date range queries
  • Auto-retry mechanism for failed requests (up to 3 attempts)
  • Memory-efficient cache with automatic cleanup
  • Automatic token refresh every 12 hours
  • Type-safe event system
  • Full TypeScript support

Installation

npm install bedloop
# or
pnpm add bedloop
# or
yarn add bedloop

Quick Start

import { Client, EventType } from 'bedloop'

const client = new Client(
  {
    user: 'your-username',
    password: 'your-password',
    url: 'https://your-bedloop-instance.com'
  },
  {
    interval: 5000,
    beforeDays: 7,
    afterDays: 30
  }
)

client.connect((events) => {
  events.forEach((event) => {
    if (event.event === EventType.NEW_MESSAGE) {
      console.log('New message:', event.newMessage)
    }
  })
})

API Reference

Client

Constructor

new Client(options: ClientOptions, pollingOptions?: PollingOptions)

ClientOptions:

  • user (string): Username for authentication
  • password (string): Password for authentication
  • url (string): Base URL of your Bedloop instance
  • debug (boolean, optional): Enable debug logging (default: false)

PollingOptions:

  • interval (number): Polling interval in milliseconds (default: 5000)
  • beforeDays (number): Days to look back for bookings (default: 7)
  • afterDays (number): Days to look ahead for bookings (default: 30)

Methods

connect(callback: (events: BedloopEvent[]) => void): Promise

Connects to the Bedloop API and starts polling for events. Automatically refreshes the authentication token every 12 hours.

disconnect(): void

Disconnects from the API and cleans up resources including token refresh interval.

Event Types

BedloopEvent

interface BedloopEvent {
  event: EventType
  timestamp: Date
  newMessage?: {
    bookingId: number
    conversationId: number
    messageId: number
    message: ConversationMessage
  }
}

EventType Enum

enum EventType {
  NEW_MESSAGE = 'new_message'
}

Examples

Basic Usage

const client = new Client({
  user: 'username',
  password: 'password',
  url: 'https://api.bedloop.com'
})

await client.connect((events) => {
  events.forEach((event) => {
    console.log('Event received:', event)
  })
})

With Debug Logging

const client = new Client({
  user: 'username',
  password: 'password',
  url: 'https://api.bedloop.com',
  debug: true
})

Custom Polling Configuration

const client = new Client(
  {
    user: 'username',
    password: 'password',
    url: 'https://api.bedloop.com'
  },
  {
    interval: 10000,
    beforeDays: 14,
    afterDays: 60
  }
)

Graceful Shutdown

const client = new Client({...})
await client.connect((events) => {...})

// Clean up resources when done
client.disconnect()

Error Handling

The client automatically handles:

  • Network failures with retry logic (3 attempts, 1 second intervals)
  • Token expiration with automatic refresh every 12 hours
  • Rate limiting with configurable polling intervals
client.connect((events) => {
  try {
    events.forEach((event) => {
      // Process event
    })
  } catch (error) {
    console.error('Error processing events:', error)
  }
})

License

MIT

Author

johan12361


Note: This is an alpha release. The API may change in future versions.

bedloop