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

express-response-kit

v1.0.1

Published

Opinionated response helpers that extend Express.js response with clean, reusable, and type-safe methods.

Readme

express-response-kit

npm version Downloads License Node Build Coverage

A lightweight Express.js extension that adds semantic HTTP response helpers and enforces a consistent response structure across your API.

express-response-kit augments Express.Response with intuitive methods like res.ok(), res.badRequest(), res.internalServerError(), etc., while automatically normalizing response bodies for success and error responses.

✨ Features

  • ✅ Semantic response helpers for all HTTP status codes
  • ✅ Consistent response structure for 1xx, 2xx, 4xx, 5xx
  • ✅ No middleware required
  • ✅ No runtime configuration
  • ✅ TypeScript-first (full type augmentation)
  • ✅ Deprecated HTTP statuses are supported (with warnings)
  • ✅ Zero breaking changes to Express behavior

📦 Installation

npm install express-response-kit

or

pnpm add express-response-kit

🚀 Usage

Import the package once in your app entry point:

import "express-response-kit";

All helpers are now available on res.

🧱 Default Response Structure (v1)

For the following HTTP status ranges:

  • 1xx – Informational
  • 2xx – Success
  • 4xx – Client errors
  • 5xx – Server errors

responses are automatically wrapped using this structure:

{
  success: boolean;
  data: unknown;
}

✅ Success Responses (1xx, 2xx)

  • success is always true
  • data is the value passed to the method
  • If no value is passed, data is null

Examples

| Code | Result | |------|--------| | res.ok("hey") | { "success": true, "data": "hey" } | | res.ok({ msg: "hey" }) | { "success": true, "data": { "msg": "hey" } } | | res.ok() | { "success": true, "data": null } | | res.created({ id: 1 }) | { "success": true, "data": { "id": 1 } } |

❌ Error Responses (4xx, 5xx)

  • success is always false
  • data is the error payload (if provided)
  • If no payload is provided, data is null

Examples

| Code | Result | |------|--------| | res.badRequest("Invalid input") | { "success": false, "data": "Invalid input" } | | res.notFound() | { "success": false, "data": null } | | res.internalServerError({ reason: "DB down" }) | { "success": false, "data": { "reason": "DB down" } } |

🔁 Redirection Responses (3xx)

Redirection responses do not follow the { success, data } structure.

They rely on standard HTTP semantics and the Location header.

Examples

| Code | Behavior | |------|----------| | res.movedPermanently("/new-url") | 301 + Location: /new-url | | res.found("/login") | 302 + redirect | | res.temporaryRedirect("/retry") | 307 + redirect |

⚠️ Deprecated Status Codes

Some HTTP status codes are officially deprecated but are still supported to respect developer intent.

Examples:

  • 305 Use Proxy
  • 306 Switch Proxy

These methods:

  • Are clearly marked as @deprecated
  • Still work correctly
  • Are not blocked or altered
res.useProxy("http://proxy.example.com");

🧠 Design Philosophy

  • Keep controllers clean and expressive
  • Avoid repeating response boilerplate
  • Enforce a predictable API contract
  • Respect HTTP standards without being opinionated
  • Extend Express without changing its core behavior

🧪 Testing

  • Uses Jest + Supertest
  • Runs against an in-memory Express app
  • No real network calls
  • All response helpers are covered
npm test

🔮 Roadmap

v2 (planned)

  • Configurable response structure
  • paginated response helpers (e.g. res.paginated(data))

📄 License

MIT © 2026