
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A lightweight Node.js utility for sending consistent, standardized HTTP responses across your API endpoints
A lightweight, flexible Node.js utility for standardizing HTTP responses in Express, Fastify, or custom server frameworks. HttpReply provides a consistent, customizable way to format and send HTTP responses, with support for timestamps, error logging, and custom adapters. Available as both ES6 modules and CommonJS, with no need for .default in ES module imports.
import or require, no .default required for ES modules.Install the package via npm:
npm install http-reply
The package supports both ES6 modules and CommonJS:
// ES6 Module
import { HttpReply } from 'http-reply';
// CommonJS
const { HttpReply } = require('http-reply');
Use HttpReply to send standardized responses in your Express or Fastify application.
import { HttpReply } from 'http-reply';
import express from 'express';
const app = express();
app.get('/example', (req, res) => {
HttpReply.success(res, {
message: 'Operation successful',
data: { user: 'John Doe' },
metaData: { requestId: '12345' },
});
});
app.listen(3000, () => console.log('Server running on port 3000'));
Create a centralized HttpReply instance for consistent configuration across your application.
Create a file (e.g., responder.js):
import { HttpReply } from 'http-reply';
const reply = new HttpReply({
includeTimestamp: true,
dateFormat: 'iso',
enableLogging: true,
customFields: { apiVersion: '1.0.0' },
});
export default reply;
Use it in your routes:
import reply from './responder';
import express from 'express';
const app = express();
app.get('/example', (req, res) => {
reply.success(res, {
message: 'Custom response',
data: { id: 1 },
});
});
app.listen(3000, () => console.log('Server running on port 3000'));
Use static methods for quick responses without instantiation:
import { HttpReply } from 'http-reply';
HttpReply.created(res, {
message: 'User created',
data: { id: 123, name: 'Jane Doe' },
});
HttpReply.notFound(res, {
message: 'Resource not found',
error: 'Invalid ID',
});
HttpReply provides methods for common HTTP status codes:
| Method | Status Code | Description |
|---|---|---|
success | 200 | Successful request |
created | 201 | Resource created successfully |
accepted | 202 | Request accepted for processing |
noContent | 204 | No content to return |
badRequest | 400 | Invalid request |
unauthorized | 401 | Authentication required |
forbidden | 403 | Access denied |
notFound | 404 | Resource not found |
conflict | 409 | Resource conflict |
tooManyRequests | 429 | Rate limit exceeded |
error | 500 | Internal server error |
notImplemented | 501 | Feature not implemented |
serviceUnavailable | 503 | Service temporarily unavailable |
response | Custom | Generic response with custom status code |
Customize HttpReply with the following options when creating an instance:
| Option | Type | Default | Description |
|---|---|---|---|
includeTimestamp | Boolean | false | Include a timestamp in the response (iso or unix format). |
includeCode | Boolean | true | Include the status code in the response body. |
includeMessage | Boolean | true | Include the message in the response body. |
includeError | Boolean | true | Include error details in the response body. |
includeMetaData | Boolean | true | Include metadata in the response body. |
enableLogging | Boolean | true | Enable error logging for invalid configurations or response objects. |
stringify | Boolean | false | Stringify the response body before sending (useful for custom adapters). |
customFields | Object | {} | Additional fields to include in every response. |
dateFormat | String | 'unix' | Format for timestamps ('iso' or 'unix'). |
adapter | Function | null | Custom adapter for non-Express/Fastify frameworks. |
For non-Express/Fastify frameworks, provide a custom adapter:
import { HttpReply } from 'http-reply';
const reply = new HttpReply({
adapter: (res, statusCode, payload) => {
res.setStatusCode(statusCode);
res.setBody(payload);
return res;
},
});
reply.success(res, {
message: 'Custom adapter response',
data: { key: 'value' },
});
Using the success method with default configuration:
HttpReply.success(res, {
message: 'User fetched',
data: { id: 1, name: 'John' },
metaData: { total: 1 },
});
Output:
{
"message": "User fetched",
"data": { "id": 1, "name": "John" },
"metaData": { "total": 1 },
"code": 200
}
With includeTimestamp: true and dateFormat: 'iso':
{
"message": "User fetched",
"data": { "id": 1, "name": "John" },
"metaData": { "total": 1 },
"code": 200,
"timestamp": "2025-06-13T17:25:00.000Z"
}
We welcome contributions! To contribute:
git checkout -b feature/your-feature).git commit -m 'Add your feature').git push origin feature/your-feature).Please ensure your code follows the project's coding standards and includes tests where applicable.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, open an issue on the GitHub repository or contact the maintainer at dev182000@gmail.com.
FAQs
A lightweight Node.js utility for sending consistent, standardized HTTP responses across your API endpoints
We found that http-reply demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.