syntaxility-response-manager
v1.0.5
Published
A type-safe API response manager for Node.js, Express, NestJS, React Native, and serverless applications.
Downloads
516
Maintainers
Readme
SyntaxilitY Response Manager
A lightweight and standardized response manager for Node.js/Express projects, providing consistent HTTP responses for API operations, including generic error handling.
Features
- Standardized JSON responses for success, error, and validation cases
- Built-in handling for environment, JWT, and generic errors
- Easy integration with decorators or middleware
- Type-safe response structure
Installation
npm install syntaxility-response-managerUsage
import { SyntaxilitYResponseManager } from "syntaxility-response-manager";
import express from "express";
const app = express();
app.get("/example", (req, res) => {
try {
// Your logic
return SyntaxilitYResponseManager.HTTP_200_OK(res, { message: "Success" });
} catch (err) {
return SyntaxilitYResponseManager.HTTP_500_INTERNAL_SERVER_ERROR(res, "Something went wrong");
}
});
app.listen(3000, () => console.log("Server running on port 3000"));