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 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.
-
Consistent Response Shape: Every endpoint returns
ApiResponse<T>with standardized properties:success: Boolean indicating request statusdata: 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
IResultimplementations:Envelope.Ok(data, message): 200 OK responsesEnvelope.Created(data, uri): 201 Created responsesEnvelope.NotFound(message): 404 Not Found responsesEnvelope.BadRequest(message, errors): 400 Bad Request with validation errorsEnvelope.Unauthorized(message): 401 Unauthorized responsesEnvelope.InternalServerError(message): 500 Internal Server Error
-
Exception Handling Middleware: Automatic wrapping of unhandled exceptions into standardized error envelopes.
-
Pagination Support: Built-in
PaginationMetafor 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
Install via NuGet Package Manager:
dotnet add package Slck.Envelope