🧰 Simplify Your API Responses in Node.js with api-response-utility

GrootGroot
1 min read

Hey devs πŸ‘‹

I just released my first NPM package called api-response-utility, and I wanted to share it with you all. It’s a small utility to help format your API responses β€” success, error, and pagination β€” in a clean, consistent way.

🧠 Why I built it

In every backend project, I found myself writing the same response boilerplate:

{ success: true, message: "...", data: ... }
{ success: false, message: "Error message" }

So I packaged it into a utility you can reuse across projects.

πŸš€ Features

  • Clean success and error responses

  • Built-in pagination support

  • Super simple API

  • Fully customizable

  • Lightweight (no dependencies)

How to use

npm install api-response-utility
const {success, error} = require('api-response-utility');

res.status(200).json(success({ userId: 123 }, "User retrieved successfully"));

res.status(500).json(error("Something went wrong", 500));

NPM

Github

I'd love your thoughts! Try it out, share feedback, and feel free to contribute if you're into open source. πŸ™Œ

#NodeJS #NPM #JavaScript #OpenSource #B[ackend #ExpressJS #DevTools #API #CleanCode #WebDev

0
Subscribe to my newsletter

Read articles from Groot directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Groot
Groot