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

@021.is/spine-errors

v0.4.3

Published

ResponseDto envelope + typed exception hierarchy + framework-agnostic handler. Modeled on a proven Kotlin shared-lib.

Readme

@021.is/spine-errors

The canonical response envelope (ResponseDto) + typed exception hierarchy + framework-agnostic handler used by every product.

Modeled on a proven Kotlin shared-lib. Same contract; idiomatic TypeScript.

Why mandatory

Every HTTP endpoint and server action returns a ResponseDto<T>. No exceptions, no "this small route doesn't need it". The client and the next service both rely on the envelope's success / code / errorMessage / errorKey / errorParams / timestamp / requestId to render UI, branch logic, propagate traces, and localize errors.

Locked. Reasoning: consistent client-side handling across every app; no per-route surprise shapes; first-class i18n via errorKey.

Install

bun add @021.is/spine-errors

Use — domain code

import { BadRequestException, NotFoundException, ForbiddenException } from "@021.is/spine-errors";

export async function publishEvent(eventId: string, userId: string) {
  const event = await db.event.findUnique({ where: { id: eventId } });
  if (!event) throw new NotFoundException("Event not found", { translationKey: "event.not_found" });
  if (event.organizerId !== userId) throw new ForbiddenException();
  if (!event.poster) {
    throw new BadRequestException("Event needs a poster before publishing", {
      translationKey: "event.publish.no_poster",
    });
  }
  return db.event.update({ where: { id: eventId }, data: { status: "PUBLISHED" } });
}

Use — Next.js route handler

import { withErrorHandling, ok } from "@021.is/spine-errors/next";
import { publishEvent } from "@/server/events/publish";

export const POST = withErrorHandling(async (req: Request) => {
  const userId = await requireUser(req);
  const { eventId } = await req.json();
  const event = await publishEvent(eventId, userId);
  return Response.json(ok(event, { successMessage: "Event published" }));
});

Any thrown *Exception becomes the correct HTTP status + ResponseDto. Unknown errors → 500 + logged.

Use — Server action

import { tryAction } from "@021.is/spine-errors/next";
import { publishEvent } from "@/server/events/publish";

export async function publishEventAction(formData: FormData) {
  "use server";
  return tryAction(async () => {
    const userId = await requireUser();
    return publishEvent(formData.get("eventId") as string, userId);
  });
}

Status code is in response.code (server actions don't have HTTP status).

Exception → HTTP status map

| Exception | Status | |---|---| | BadRequestException | 400 | | UnauthorizedException | 401 | | ForbiddenException / NotAllowedException | 403 | | NotFoundException | 404 | | ConflictException | 409 | | ExpectationFailedException | 417 | | RateLimitedException | 429 (+ Retry-After) | | SomethingWentWrongException / anything else | 500 |

i18n

Every exception subclass accepts translationKey + translationParams. These flow into ResponseDto.errorKey + errorParams. The client's i18n runtime (@021.is/spine-i18n) reads them and renders the localized message, falling back to errorMessage when no key exists.

Testing

bun run test

Real unit tests, no mocks (this package has no I/O).