Migration Before And After

Codemod

Walk every codebase through the same upgrade

Show what changes, explain why, then apply it everywhere. The diff lives in source control, not a memo.

Before

Imperative session handling

Manual cookie reads, race conditions on rotation, and silent failures when refresh times out.

session.tsv1
// Read the refresh token by hand
const cookie = req.headers.cookie;
const token = parseCookie(cookie, "rt");
if (!token) throw new Error(401);
// Try to refresh, hope it works
let session;
try {
session = refresh(token);
} catch {
session = null;
}

After

Declarative refresh with retries

One call, typed error states, automatic backoff, and a stale window that survives concurrent requests.

session.tsv2
// Single call replaces the whole flow
import { refresh } from "@beste/auth";
const session = await refresh.fromCookies(req, {
retry: { on: "5xx", max: 3 },
staleAfter: "5s",
});
// Errors are typed, not thrown silently
if (!session.ok) {
return reply(session.error);
}
return session.value;

12 lines removed · 8 lines added

across 14 files in your repo

About this block

Migration Before And AfterPRO

Browser-chrome card pairing a before/after code migration — eyebrow + title + description above each pane, monochrome syntax, and an apply-migration footer with diff summary. Every label is editable; no media props required.

More Showcase blocks

View all Showcase
PRO

showcase34

Polyglot Code Comparison

PRO

showcase23

Component Preview With Code Editor

PRO

showcase20

Code Editor With Environments Panel

Get Pro access