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

statusmith

v1.0.6

Published

Zero-dependency HTTP status code, dynamic messages and response handler for backend APIs.

Downloads

208

Readme

Statusmith

Zero-dependency HTTP status codes, dynamic messages and response handler for Node.js backends.

Stop memorizing status codes. Stop rewriting the same messages. statusmith gives you a clean, consistent layer for every API response.


Installation

npm install statusmith


Import

import {
  STATUS,
  STATUS_CAPS,
  MESSAGE,
  MESSAGE_CAPS,
  sendResponse,
} from "statusmith";

Status Codes

camelCase

STATUS.success; // 200
STATUS.created; // 201
STATUS.accepted; // 202
STATUS.noContent; // 204
STATUS.badRequest; // 400
STATUS.unauthorized; // 401
STATUS.forbidden; // 403
STATUS.notFound; // 404
STATUS.conflict; // 409
STATUS.unprocessableEntity; // 422
STATUS.tooManyRequests; // 429
STATUS.serverError; // 500
STATUS.serviceUnavailable; // 503

SCREAMING_SNAKE_CASE

STATUS_CAPS.SUCCESS;
STATUS_CAPS.NOT_FOUND;
STATUS_CAPS.SERVER_ERROR;
// same values, different naming style

Messages

Messages are dynamic functions. Pass a custom message or use the built-in default.

// default
MESSAGE.success(); // "Request completed successfully."
MESSAGE.notFound(); // "The requested resource was not found."
MESSAGE.unauthorized(); // "You are not authorized. Please login and try again."
MESSAGE.serverError(); // "Something went wrong on our end. Please try again later."

// custom
MESSAGE.success("User registered successfully");
MESSAGE.notFound("Product not found");
MESSAGE.conflict("Email already exists");

Same pattern for MESSAGE_CAPS:

MESSAGE_CAPS.SUCCESS("User registered successfully");
MESSAGE_CAPS.NOT_FOUND();

sendResponse

A clean response utility. Builds a structured JSON response and sends it.

sendResponse(res, statusCode, message, data, meta);

| Parameter | Type | Required | Description | | ------------ | ------ | -------- | ------------------------------------- | | res | Object | ✅ | Express response object | | statusCode | Number | ✅ | HTTP status code | | message | String | ✅ | Response message | | data | Any | ❌ | Response payload — skipped if null | | meta | Object | ❌ | Extra info — pagination, token, count |

Response shape

{
  "success": true,
  "statusCode": 200,
  "message": "User registered successfully",
  "data": {},
  "meta": {}
}

data and meta only appear when provided.


Examples

Basic

// success with data
sendResponse(res, STATUS.success, MESSAGE.success("User fetched"), user);

// error without data
sendResponse(res, STATUS.notFound, MESSAGE.notFound("User"));

With meta — pagination

sendResponse(res, STATUS.success, MESSAGE.success(), users, {
  page: 1,
  limit: 10,
  total: 100,
});

Real world routes

import { STATUS, MESSAGE, sendResponse } from "statusmith";

// GET user
app.get("/user/:id", async (req, res) => {
  const user = await User.findById(req.params.id);

  if (!user) {
    return sendResponse(res, STATUS.notFound, MESSAGE.notFound("User"));
  }

  sendResponse(
    res,
    STATUS.success,
    MESSAGE.success("User fetched successfully"),
    user,
  );
});

// POST register
app.post("/register", async (req, res) => {
  const existing = await User.findOne({ email: req.body.email });

  if (existing) {
    return sendResponse(
      res,
      STATUS.conflict,
      MESSAGE.conflict("Email already exists"),
    );
  }

  const user = await User.create(req.body);
  sendResponse(
    res,
    STATUS.created,
    MESSAGE.created("User registered successfully"),
    user,
  );
});

// DELETE
app.delete("/user/:id", async (req, res) => {
  await User.findByIdAndDelete(req.params.id);
  sendResponse(res, STATUS.noContent, MESSAGE.noContent());
});

Why statusmith

| Without statusmith | With statusmith | | ----------------------------------------------------- | -------------------------------------------------------------- | | res.status(404).json({ message: "User not found" }) | sendResponse(res, STATUS.notFound, MESSAGE.notFound("User")) | | Hardcoded numbers everywhere | Semantic, readable constants | | Inconsistent messages across routes | One source of truth | | Different response shapes per developer | Unified structure |


License

MIT © statusmith