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

@seamos/connect

v0.1.2

Published

WebSocket and HTTP connectivity utilities for SeamOS

Readme

@seamos/connect

WebSocket and HTTP connectivity utilities for SeamOS. Provides automatic port resolution from CCU, a managed WebSocket client with auto-reconnect, and a fetch wrapper — all using just endpoint paths.

Installation

npm install @seamos/connect

Quick Start

import {
  initPorts,
  createWebSocketClient,
  seamosFetch,
} from '@seamos/connect';

// 1. Initialize port mapping (call once at app startup)
await initPorts();

// 2. WebSocket — just pass the path
const client = createWebSocketClient('/ws', {
  autoReconnect: true,
  events: {
    open: () => console.log('Connected'),
    message: (e) => console.log('Message:', e.data),
    close: () => console.log('Disconnected'),
  },
});

// 3. HTTP fetch — just pass the path
const response = await seamosFetch('/api/data');
const data = await response.json();

API

initPorts()

Fetches the assigned port from the CCU (get_assigned_ports endpoint) and stores it globally. Must be called once before using any other port-dependent function.

Returns: Promise<void>

getAssignedPort()

Returns the assigned port number.

Returns: number

Throws if initPorts() has not been called.

getAssignedPorts()

Returns the raw port mapping object from the CCU.

Returns: Record<string, number>

Throws if initPorts() has not been called.

createWebSocketClient(path, options?)

Creates a WebSocket client connected to the given path.

Parameters:

  • path (string): Endpoint path (e.g., '/ws')
  • options (optional):
    • protocols: WebSocket sub-protocols
    • events: Event handlers object with open, message, close, error handlers
    • autoReconnect: Enable auto-reconnect (default: false)
    • reconnectInterval: Reconnect delay in ms (default: 3000)

Returns: { socket, close() }

seamosFetch(path, init?)

Fetch wrapper that automatically uses the resolved host and port.

Parameters:

  • path (string): API endpoint path (e.g., '/api/data')
  • init (optional): Standard RequestInit options (method, headers, body, etc.)

Returns: Promise<Response>

sendJson(socket, payload)

Sends a JSON-serialized payload through a WebSocket.

Throws if the socket is null or not in OPEN state.

closeWebSocketSafe(socket, code?, reason?)

Safely closes a WebSocket connection. No-op if null or already closed.

isProperJson(payload)

Checks whether the given payload is valid JSON (non-null object).

Returns: boolean

License

MIT