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

@common-sense/error-iq

v0.1.2

Published

TypeScript-first RFC 9457 Problem Details + HTTP error with Express/Fastify/Koa/Nest middlewares.

Downloads

169

Readme

@common-sense/error-iq

TypeScript-first RFC 9457 Problem Details built around explicit HttpError classes, with plug-and-play Express, Fastify, Koa, and Nest integrations. Defaults are standard-compliant and ready out-of-the-box.

Install

pnpm add @common-sense/error-iq

Core usage

import { BadRequest, UnprocessableContent, ServiceUnavailable, contentTypeProblemJson } from '@common-sense/error-iq';

throw new BadRequest('Invalid input');
throw new UnprocessableContent('Bad data');
throw new ServiceUnavailable('Try later');
  • contentTypeProblemJson = application/problem+json

More examples

// 401 Unauthorized with WWW-Authenticate
import { Unauthorized } from '@common-sense/error-iq';
throw new Unauthorized('Invalid token', /* instance */ null, /* extensions */ null, /* WWW-Authenticate */ 'Bearer realm="api", error="invalid_token"');
// 409 Conflict with Retry-After (seconds)
import { Conflict } from '@common-sense/error-iq';
throw new Conflict('Resource conflict', /* instance */ null, /* extensions */ null, /* retryAfter */ 60);
// 500 Internal Server Error with detail, instance, and extensions
import { InternalServerError } from '@common-sense/error-iq';
throw new InternalServerError(
  'Unexpected failure while processing order 123',
  '/orders/123',
  { traceId: '7f5c1a2b', component: 'payments', severity: 'critical' },
);

Express

import express from 'express';
import { express as erriq, UnprocessableContent } from '@common-sense/error-iq';

const app = express();

app.get('/demo', (_req, _res) => {
  throw new UnprocessableContent('Bad data');
});

// 404 then error
app.use(erriq.notFoundHandler());
app.use(erriq.errorHandler());

app.listen(3000);

Fastify

import Fastify from 'fastify';
import { registerFastifyHandler } from '@common-sense/error-iq/fastify';
import { Conflict } from '@common-sense/error-iq';

const app = Fastify();
registerFastifyHandler(app);

app.get('/demo', async () => {
  throw new Conflict('Conflict');
});

app.listen({ port: 3000 });

Koa

import Koa from 'koa';
import { errorMiddleware } from '@common-sense/error-iq/koa';
import { NotFound } from '@common-sense/error-iq';

const app = new Koa();
app.use(errorMiddleware());

app.use(() => {
  throw new NotFound('Nope');
});

app.listen(3000);

Nest

import { NestFactory } from '@nestjs/core';
import { ProblemFilter } from '@common-sense/error-iq/nest';
import { Forbidden } from '@common-sense/error-iq';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalFilters(new ProblemFilter());
  await app.listen(3000);
}

// In controllers/services
throw new Forbidden('Not allowed');

The middlewares automatically serialize thrown errors as RFC 9457 Problem Details with the correct Content-Type and relevant headers (e.g., WWW-Authenticate, Retry-After, Allow) when provided by the error class.

RFC 9457 fields (Problem Details)

  • type: URI identifying the problem type (use about:blank if none)
  • title: Short, human-readable summary of the problem type
  • status: HTTP status code for this occurrence
  • detail: Human-readable explanation specific to this occurrence
  • instance: URI reference identifying the specific occurrence
  • extensions: Additional application-specific members are allowed

Why RFC 9457 and why this library?

  • Interoperability: Standard, predictable error responses across services and clients
  • Better DX: Strongly-typed error classes per status code; no ad-hoc shapes
  • Framework parity: Drop-in middleware/filters for Express, Fastify, Koa, and Nest
  • Headers propagation: Properly forwards standard headers (WWW-Authenticate, Retry-After, Allow)
  • Sensible defaults: application/problem+json out of the box

API (surface)

  • Client error classes: BadRequest, Unauthorized, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, ProxyAuthenticationRequired, RequestTimeout, Conflict, Gone, LengthRequired, PreconditionFailed, PayloadTooLarge, URITooLong, UnsupportedMediaType, RangeNotSatisfiable, ExpectationFailed, IAmATeapot, UnprocessableContent, TooEarly, UpgradeRequired, PreconditionRequired, TooManyRequests, RequestHeaderFieldsTooLarge, UnavailableForLegalReasons
  • Server error classes: InternalServerError, NotImplemented, BadGateway, ServiceUnavailable, GatewayTimeout, HTTPVersionNotSupported, InsufficientStorage, LoopDetected, NotExtended, NetworkAuthenticationRequired
  • contentTypeProblemJson – application/problem+json
  • Framework adapters: @common-sense/error-iq/express, @common-sense/error-iq/fastify, @common-sense/error-iq/koa, @common-sense/error-iq/nest

License

MIT