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

@tgwrapper/starter-migration

v0.2.6

Published

Migration starter for moving Telegraf or grammY bots to TGWrapper

Readme

TGWrapper Migration Starter

Requirements: Node.js >=22.13, pnpm, tsx, Redis >=6.2

Use case: side-by-side migration reference from Telegraf-style handlers to TGWrapper.

Included: before/after sample entrypoints, Redis session adapter wiring, and production deployment notes.

Template package for migrating a stateful Telegram bot from Telegraf-style handlers to TGWrapper with Redis-backed sessions, Compare-and-Swap writes, and structured logs.

Use this starter when you want a side-by-side migration reference:

  • src/bot-before.ts shows the Telegraf baseline.
  • src/bot-after.ts shows the TGWrapper implementation.
  • dist/ contains built JavaScript entrypoints after pnpm build.

Quick Start

pnpm create @tgwrapper my-migration-bot --template migration
cd my-migration-bot
cp .env.example .env
pnpm install

Edit .env, then run one of the entrypoints:

export BOT_TOKEN="your_botfather_token"
export REDIS_URL="redis://localhost:6379"

pnpm tsx src/bot-before.ts
pnpm tsx src/bot-after.ts

Expected TGWrapper startup output:

{
  "event": "startup",
  "serviceName": "registration-service",
  "mode": "polling",
  "redisUrl": "redis://localhost:6379"
}

Environment Variables

| Name | Required | Default | Description | | ----------- | -------- | ------------------------ | ------------------------------------------------------- | | BOT_TOKEN | yes | none | Telegram bot token from BotFather. | | REDIS_URL | no | redis://localhost:6379 | Redis connection used by the TGWrapper session adapter. |

What Gets Installed

The npm package is a project template, not a library API. It ships:

  • src/bot-before.ts
  • src/bot-after.ts
  • compiled dist/ files
  • README.md
  • CHANGELOG.md
  • tsconfig.json
  • .env.example

Copy the files into your own application and then change package name, commands, Redis topology, tenant IDs, bot IDs, telemetry destinations, and handlers.

What You Still Need to Implement

  • Your application-specific session state schema and migration path.
  • The production event flow and webhook/runtime integration.
  • Secret management for BOT_TOKEN and REDIS_URL.
  • Any stateful user routing or service-specific business logic.

Manual Copy Fallback

Power users can install this package directly and copy the template files:

pnpm add -D @tgwrapper/starter-migration
mkdir my-migration-bot
cp -R node_modules/@tgwrapper/starter-migration/{src,tsconfig.json,.env.example} my-migration-bot/

Migration Checklist

  • Install @tgwrapper/core, @tgwrapper/adapter-redis, and @tgwrapper/observability.
  • Define a strict session state interface with version: number.
  • Replace implicit ctx.session mutations with explicit compareAndSet writes.
  • Replace ctx.reply(...) with bot.sendMessage(...).
  • Attach observability during startup.
  • Handle SIGINT and SIGTERM to stop polling and close Redis.

How This Maps to Production

This starter uses polling because it is easiest for local migration work. For production:

  • switch the TGWrapper client to webhook mode;
  • expose the webhook handler from your HTTP platform;
  • keep Redis shared across all running instances;
  • route JSON logs to your production log pipeline;
  • keep BOT_TOKEN and Redis credentials in your secret manager.