View as Json

API Response Formatter

A standardized, type-safe API response wrapper for Express applications.

Installation Guide

npx servercn-cli@latest add response-formatter

Usage Example

import { Request, Response } from "express";
import { ApiResponse } from "../utils/api-response";
 
export async function healthCheck(_req: Request, res: Response) {
  return ApiResponse.ok(res, "Service is healthy");
}

Response

{
  "success": true,
  "message": "Service is healthy",
  "statusCode": 200
}

File & Folder Structure

Loading files...
npx servercn-cli@latest add response-formatter

Contributed by