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

@kasifraza/nestjs-response-formatter

v1.0.1

Published

Standardized API response wrapper for NestJS with pagination, error formatting, and success responses

Readme

@kasifraza/nestjs-response-formatter

npm package license downloads Tests

Standardized API response wrapper for NestJS with automatic pagination detection, error formatting, and custom messages.

Install

npm install @kasifraza/nestjs-response-formatter

Setup

// main.ts
import { ResponseInterceptor, ResponseExceptionFilter } from '@kasifraza/nestjs-response-formatter';
import { Reflector } from '@nestjs/core';

const app = await NestFactory.create(AppModule);
app.useGlobalInterceptors(new ResponseInterceptor(new Reflector()));
app.useGlobalFilters(new ResponseExceptionFilter());

Usage

Basic response (auto-wrapped)

@Get()
findAll() {
  return [{ id: 1, name: 'John' }];
}
// Output: { success: true, statusCode: 200, message: "Success", data: [...], timestamp: "..." }

Custom message

import { ResponseMessage } from '@kasifraza/nestjs-response-formatter';

@Post()
@ResponseMessage('User created successfully')
create(@Body() dto: CreateUserDto) {
  return this.userService.create(dto);
}
// Output: { success: true, statusCode: 201, message: "User created successfully", data: {...} }

Pagination (auto-detected)

Return a PaginatedResult shape and meta is added automatically:

import { PaginationDto } from '@kasifraza/nestjs-response-formatter';

@Get()
async findAll(@Query() query: any) {
  const pagination = new PaginationDto(query);
  const [items, total] = await this.repo.findAndCount({
    skip: pagination.skip,
    take: pagination.limit,
  });
  return { data: items, total, page: pagination.page, limit: pagination.limit };
}
// Output: { success: true, data: [...], meta: { page: 1, limit: 10, total: 50, totalPages: 5, hasNext: true, hasPrev: false } }

Skip formatting

import { SkipResponseFormat } from '@kasifraza/nestjs-response-formatter';

@Get('health')
@SkipResponseFormat()
health() {
  return { status: 'ok' }; // returned as-is
}

Error responses (automatic)

{
  "success": false,
  "statusCode": 404,
  "message": "User not found",
  "timestamp": "2024-01-01T00:00:00.000Z"
}

Validation errors:

{
  "success": false,
  "statusCode": 400,
  "message": "email must be an email",
  "errors": ["email must be an email", "name should not be empty"],
  "timestamp": "..."
}

API

| Export | Description | |--------|-------------| | ResponseInterceptor | Global interceptor that wraps all responses | | ResponseExceptionFilter | Global filter for consistent error responses | | ResponseMessage(msg) | Decorator to set custom success message | | SkipResponseFormat() | Decorator to skip formatting for a route | | PaginationDto | DTO with page, limit, skip from query params |

Interfaces

interface ApiResponse<T> {
  success: boolean;
  statusCode: number;
  message: string;
  data: T;
  meta?: PaginationMeta;
  timestamp: string;
}

interface PaginatedResult<T> {
  data: T[];
  total: number;
  page: number;
  limit: number;
}

License

MIT