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

@qemuguest/site-chat-server

v0.1.0

Published

Backend for website live chat: Web-standard handlers, storage adapters (D1, SQLite, memory) and relays to SimpleX (one chat per customer), Telegram and email.

Readme

@qemuguest/site-chat-server

Backend for website live chat. Web-standard handlers (Request → Response), pluggable storage, and relays to SimpleX (one chat per customer, via @qemuguest/site-chat-simplex-bridge), Telegram (two-way) and email. Pairs with @qemuguest/site-chat-widget.

npm i @qemuguest/site-chat-server
import { createSiteChat, sqlStore, d1Driver, simplexRelay, telegram, emailAlerts, resendEmail } from "@qemuguest/site-chat-server";

const chat = createSiteChat({
  store: sqlStore(d1Driver(env.DB)),
  basePath: "/api/site-chat",              // where you mount it (default)
  channels: [
    simplexRelay({ secret: env.SITE_CHAT_SECRET }),
    telegram({ botToken: env.TELEGRAM_BOT_TOKEN, webhookSecret: env.TELEGRAM_WEBHOOK_SECRET }),
    emailAlerts({ to: "[email protected]", send: resendEmail({ apiKey: env.RESEND_API_KEY, from: "Site <[email protected]>" }) }),
  ],
  adminUrl: (id) => `https://example.com/admin/messages?c=${id}`,   // linked from alerts
});

// Any framework: hand it the Request.
export default { fetch: (req: Request) => chat.fetch(req) };             // Cloudflare Worker
export const GET = (req: Request) => chat.fetch(req), POST = GET;        // Next.js app/api/site-chat/[...path]/route.ts
app.all("/api/site-chat/*", (c) => chat.fetch(c.req.raw));               // Hono

chat.handle(req) resolves to null for paths that aren't its own, so you can mount it alongside other routes.

Endpoints (under basePath)

| Method & path | Who | What | | --- | --- | --- | | POST /messages | widget | start / continue a chat, send { text } or { details: { name, email, phone } } | | GET /messages?id&token&after | widget | poll for replies | | POST /contact | widget | contact form { name, email, phone?, business?, message } | | POST /telegram/webhook | Telegram | bot updates (checked against webhookSecret) | | GET /relay/outbox, POST /relay/ack, POST /relay/reply | SimpleX bridge | Authorization: Bearer <secret> |

Built in: per-IP limit on new conversations, per-conversation message limit, honeypot field, visitor tokens (only the visitor can read their thread), IPs stored only as salted hashes.

Storage

  • memoryStore() for tests and dev.
  • sqlStore(driver, { prefix: "sc_" }) with d1Driver(env.DB) (Cloudflare D1) or sqliteDriver(db) (better-sqlite3, node:sqlite). Create tables with await store.migrate() or run schemaSql() as a migration.
  • Or implement the ChatStore interface for anything else.

Admin

await chat.admin.list();                // conversations with last message + unread state
await chat.admin.get(id);               // { conversation, messages }
await chat.admin.reply(id, "On it!");   // appears live in the visitor's chat, mirrored to Telegram / SimpleX
await chat.admin.markRead(id);
await chat.admin.unreadCount();

Telegram

  1. Create a bot with @BotFather; pick any long random webhookSecret.
  2. const tg = telegram({ botToken, webhookSecret }), pass it in channels, then once: const { link } = await tg.connect("https://example.com/api/site-chat/telegram/webhook").
  3. Open link and press Start. That chat is now the only one that gets messages and can answer. Reply to a relayed message to answer the visitor live.

SimpleX

Add simplexRelay({ secret }) and run the bridge next to your SimpleX app. See @qemuguest/site-chat-simplex-bridge.

Custom channels

const slack: Channel = {
  name: "slack",
  async notify(e, ctx) { if (e.type === "visitor") await postToSlack(e.conversation, e.body); },
  routes: { async "POST /slack/events"(req, ctx) { /* … */ await ctx.agentReply(conversationId, text, "slack"); return new Response("ok"); } },
};

MIT