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

@ironstack/replyify

v0.1.0

Published

Lightweight Node.js API response formatter for consistent success, error, validation, and pagination replies.

Readme

@ironstack/replyify

Lightweight Node.js API response formatting for consistent success, error, validation, and pagination replies.

Docs: https://akram-ashraf.github.io/replyify/

Why replyify

Most backends start with simple route handlers and drift into inconsistent response shapes:

res.json(data)
res.status(400).json({ error: "Invalid request" })
throw new Error("User not found")

That creates problems for frontend consumers, SDKs, error handling, and long-term maintenance.

replyify gives you one predictable contract for:

  • success replies
  • error replies
  • validation errors
  • pagination metadata
  • Express handler wrapping
  • Express error middleware

What it solves

With replyify, routes move from ad hoc JSON to a stable reply format:

return ok(user)
throw apiError("NOT_FOUND", "User not found")
return paginate(users, { page, limit, total })

Install

npm install @ironstack/replyify

Response shape

Success:

{
  success: true,
  code: "OK",
  message: "Success",
  data: {},
  meta: {}
}

Error:

{
  success: false,
  code: "NOT_FOUND",
  message: "User not found",
  errors: [],
  meta: {}
}

Pagination:

{
  success: true,
  code: "OK",
  message: "Success",
  data: [],
  meta: {
    page: 1,
    limit: 10,
    total: 100,
    pages: 10
  }
}

Usage

Basic replies

import { fail, ok, paginate, validationError, apiError } from "@ironstack/replyify"

return ok({ id: 1, name: "Asha" })

return fail("BAD_REQUEST", "Invalid request")

return validationError([
  { field: "name", message: "Required" }
])

return paginate(users, {
  page: 1,
  limit: 10,
  total: 42
})

throw apiError("NOT_FOUND", "User not found")

Express

import express from "express"
import { ok, apiError } from "@ironstack/replyify"
import { replyHandler, errorMiddleware } from "@ironstack/replyify/express"

const app = express()

app.get(
  "/users/:id",
  replyHandler(async (req) => {
    const user = req.params.id === "1"
      ? { id: "1", name: "Asha" }
      : null

    if (!user) {
      throw apiError("NOT_FOUND", "User not found")
    }

    return ok(user)
  })
)

app.use(errorMiddleware())

Before and after

Before:

app.get("/users", async (req, res) => {
  res.json(users)
})

After:

app.get(
  "/users",
  replyHandler(async () => {
    return ok(users)
  })
)

API

ok(data, message?, meta?)

Builds a success reply result.

fail(code, message, errors?, meta?)

Builds an error reply result without throwing.

paginate(data, options)

Builds a paginated reply result with page metadata.

apiError(code, message, errors?, meta?)

Creates an ApiError instance.

validationError(errors, message?)

Builds a validation error reply.

ApiError

Error class with code, status, message, errors, and meta.

replyHandler(fn)

Express wrapper that executes your route, formats returned reply results, and sends JSON automatically.

errorMiddleware()

Express middleware that normalizes thrown errors and sends replyify-formatted JSON.

Status mapping

  • OK -> 200
  • CREATED -> 201
  • BAD_REQUEST -> 400
  • UNAUTHORIZED -> 401
  • FORBIDDEN -> 403
  • NOT_FOUND -> 404
  • CONFLICT -> 409
  • VALIDATION_ERROR -> 422
  • INTERNAL_ERROR -> 500

Development

npm run typecheck
npm run test
npm run build

License

MIT