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

@greyw0rks/poker-backend

v1.0.3

Published

No-Limit Texas Hold'em backend for Celo MiniPay

Readme

CeloPoker — Backend

No-Limit Texas Hold'em game server powering CeloPoker. Built with Node.js, Express, and Socket.io.

Stack

  • Runtime: Node.js 20+
  • Framework: Express + Socket.io
  • Blockchain: Celo Mainnet via ethers.js v6
  • Contract: PokerEscrow.sol at 0x4EdB68a7EE036D7438f6E8fcBE43b35539e55Ec3
  • Token: cUSD 0x765DE816845861e75A25fCA122bb6898B8B1282a

Quick Start

npm install
cp .env.example .env   # fill in your keys
npm start              # starts on PORT (default 8080)

Environment Variables

PORT=8080
NODE_ENV=production

# Blockchain
CELO_NETWORK=celo
POKER_ESCROW_ADDRESS=0x4EdB68a7EE036D7438f6E8fcBE43b35539e55Ec3
CUSD_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
OPERATOR_KEY=0xYOUR_OPERATOR_PRIVATE_KEY
OPERATOR_ADDRESS=0xYOUR_OPERATOR_ADDRESS
HOUSE_ADDRESS=0xYOUR_HOUSE_ADDRESS


## API Reference

### Health

GET /health


### Tables

GET /tables — list open tables GET /tables/:id — get table state


### Difficulty Rooms (vs Bots)

POST /rooms/create — create a difficulty room body: { hostName, difficulty: easy|normal|hard|super|private, address } returns: { tableId, code, humanPlayerId, buyInUSD }

GET /rooms/:code — join by 6-char invite code GET /rooms — list open rooms


| Difficulty | Buy-in | Bots |
|------------|--------|------|
| easy       | $0.10  | 3 casual |
| normal     | $0.15  | 3 smart |
| hard       | $0.50  | 3 aggressive |
| super      | $1.00  | 3 GTO |
| private    | $0.20  | 0 (friends only) |

### Vouchers

POST /vouchers/redeem — { code, address } GET /vouchers/balance/:address — check games left

POST /admin/vouchers — create voucher (requires secret) body: { secret, code, gamesPerClaim, maxClaims, buyInPerGame, daysValid } GET /admin/vouchers?secret= — list all vouchers DELETE /admin/vouchers/:code?secret= — deactivate


### Stats & Leaderboard

GET /leaderboard — top 10 players by USD won GET /stats/:address — individual player stats


### Dev Mode

POST /dev/human-bot-table — create human vs bots table (DEV_MODE only) body: { humanName, botCount, minBuyInUSD }


## Socket.io Events

### Client → Server
| Event | Payload |
|-------|---------|
| `join_table` | `{ tableId, name, address, buyInUSD, humanPlayerId? }` |
| `action` | `{ tableId, type: fold\|check\|call\|raise\|allin, amount? }` |
| `get_state` | `{ tableId }` |
| `get_cards` | `{ tableId }` |

### Server → Client
| Event | Description |
|-------|-------------|
| `connected` | Socket connected |
| `join_ok` | Joined successfully — includes `playerIdx` (your seat) |
| `game_state` | Full table state update |
| `hand_started` | New hand began |
| `hole_cards` | Your 2 private cards `{ cards: ['As', 'Kd'] }` |
| `street_dealt` | Flop/Turn/River dealt |
| `player_action` | A player acted |
| `hand_complete` | Hand finished with winner + payouts |
| `table_finished` | All hands done, final results |
| `error` | Something went wrong |

## Architecture

server/ index.js — Express app + Socket.io + all routes tableManager.js — Table lifecycle, lobby timers, game state voucherManager.js — Voucher codes (JSON file storage) winningsManager.js — Player stats + leaderboard (JSON file storage)

engine/ gameEngine.js — NLHE state machine (PREFLOP→FLOP→TURN→RIVER→SHOWDOWN) handEvaluator.js — 7-card best hand evaluator deck.js — 52-card deck + Fisher-Yates shuffle potManager.js — Side pot calculator for all-in scenarios

bots/ botPlayer.js — 5 bot strategies: RANDOM, CALL_STATION, FOLDER, AGGRESSIVE, GTO_BASIC

data/ — Persistent JSON files (vouchers, balances, winnings)


## Game Rules

- **Players:** 3–6 per table
- **Timer:** 1 minute lobby, 30 seconds per action
- **Payout:** 90% to winner, 10% house fee
- **Blockchain:** All payouts executed on-chain via `batchPayout()`

## Deploying to Railway

1. Connect this repo to Railway
2. Set all environment variables listed above
3. Railway auto-detects Node.js and runs `npm start`
4. Set `PORT=8080` in Railway variables

## Admin: Creating Vouchers