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

@digelo/cobid

v1.0.2

Published

Minimal in-memory auction server with WebSockets and Signal events

Downloads

249

Readme

@digelo/cobid

Minimal in-memory auction server using WebSockets and @digelo/signal for events.

Architecture

Cobid architecture diagram

Think of it as three small parts working together: the HTTP server speaks REST and WebSocket, the in-memory store keeps the auction state and validates bids, and Signal acts like the internal announcer that broadcasts new bids and items to every connected client.

Install

npm install @digelo/cobid

Run

npm run start

The server listens on http://localhost:3000 by default.

Frontend (optional)

The frontend lives in this GitHub repo under public/, but it is excluded from the npm package. To serve it locally from the repo:

SERVE_FRONTEND=true npm run start

REST API

  • GET /api/auctions - list items and highest bids
  • POST /api/auctions - create a new auction item

WebSocket

Send bids:

{ "type": "bid", "itemId": "...", "amount": 125, "bidder": "Alex" }

Receive updates:

{ "type": "highestBid", "itemId": "...", "highestBid": 125 }
{ "type": "newItem", "item": { "id": "...", "title": "..." } }

Publish checklist

  • Update version in package.json
  • Run npm pack and inspect the tarball contents
  • Run npm publish --access public

Making bids persistent

You can replace the in-memory store with a database-backed implementation without changing the rest of the app. The server only depends on the store methods below.

1) Keep the same store interface

AuctionStore exposes three methods that the server calls:

  • list()
  • createItem({ title, startingBid })
  • placeBid({ itemId, amount, bidder })

Create a new file (for example, src/persistentStore.js) that implements the same method signatures, but uses your database instead of a Map.

2) Use a transactional or atomic bid update

To prevent race conditions, make bid updates atomic in the database. The logic is:

  • Load the item by ID
  • Reject if the new bid is not higher
  • Update the highest bid and bidder

In SQL, prefer a single conditional update (or a transaction) so two users cannot both win with the same previous price.

3) Swap the store in the server

Update the import in src/server.js to use your new store:

import { PersistentStore } from "./persistentStore.js";
const store = new PersistentStore();

4) Remove seeding and load from DB

Instead of calling store.createItem(...) at startup, load initial items from the database or start with an empty table/collection.

5) Keep Signal events as-is

The Signal calls (emitHighestBid, emitNewItem) can stay the same. Just emit after the database write succeeds.

If you want a concrete adapter for a specific database (SQLite, Postgres, MongoDB), tell me which one and I can sketch it out.