Skip to content

chandru415/Slck.Envelope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slck.Envelope

A lightweight, opinionated library for ASP.NET Core minimal APIs that standardizes your response body
It provides a consistent envelope (`ApiResponse`), `IResult` wrappers for common HTTP status codes, and middleware to catch unhandled exceptions.



🔦 Slck.Envelope

Slck.Envelope is a lightweight, opinionated library for ASP.NET Core minimal APIs that standardizes API responses into a consistent envelope format. It provides a structured way to handle success responses, errors, and metadata across your entire API.


✨ Features

  • Consistent Response Shape: Every endpoint returns ApiResponse<T> with standardized properties:

    • success: Boolean indicating request status
    • data: The response payload (null on error)
    • error: Error details (null on success)
    • meta: Optional metadata (pagination, timestamps, etc.)
  • Minimal API Integration: Seamless integration with ASP.NET Core minimal APIs using IResult implementations:

    • Envelope.Ok(data, message): 200 OK responses
    • Envelope.Created(data, uri): 201 Created responses
    • Envelope.NotFound(message): 404 Not Found responses
    • Envelope.BadRequest(message, errors): 400 Bad Request with validation errors
    • Envelope.Unauthorized(message): 401 Unauthorized responses
    • Envelope.InternalServerError(message): 500 Internal Server Error
  • Exception Handling Middleware: Automatic wrapping of unhandled exceptions into standardized error envelopes.

  • Pagination Support: Built-in PaginationMeta for paginated list endpoints with:

    • Page number
    • Page size
    • Total items
    • Total pages
    • Navigation links
  • Developer Experience:

    • CamelCase JSON serialization
    • Ignore null properties
    • Extension methods for common scenarios
    • Type-safe response factories

📦 Installation

Install via NuGet Package Manager:

dotnet add package Slck.Envelope

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages