@navios/core 0.9.2 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +1 -1
- package/docs/README.md +3 -1
- package/docs/exceptions.md +37 -1
- package/lib/{index-B2ulzZIr.d.cts → index-BOBeqs9U.d.cts} +445 -2
- package/lib/index-BOBeqs9U.d.cts.map +1 -0
- package/lib/{index-C8lUQePd.d.mts → index-CVlRKxp2.d.mts} +445 -2
- package/lib/index-CVlRKxp2.d.mts.map +1 -0
- package/lib/index.cjs +37 -2
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +2 -2
- package/lib/legacy-compat/index.cjs +2 -2
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +7 -5
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +7 -5
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-Baabu2R8.mjs → src-DqPmV_Qw.mjs} +1743 -26
- package/lib/src-DqPmV_Qw.mjs.map +1 -0
- package/lib/{src-Cu9OAnfp.cjs → src-dwaFq8LO.cjs} +1948 -171
- package/lib/src-dwaFq8LO.cjs.map +1 -0
- package/lib/testing/index.cjs +2 -2
- package/lib/testing/index.d.cts +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.mjs +1 -1
- package/lib/{use-guards.decorator-EvI2m2DK.cjs → use-guards.decorator-C_cBWxyM.cjs} +2 -2
- package/lib/{use-guards.decorator-EvI2m2DK.cjs.map → use-guards.decorator-C_cBWxyM.cjs.map} +1 -1
- package/package.json +4 -4
- package/src/__tests__/responders.spec.mts +339 -0
- package/src/index.mts +1 -0
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -1
- package/src/legacy-compat/attribute.factory.mts +12 -26
- package/src/responders/enums/framework-error.enum.mts +38 -0
- package/src/responders/enums/index.mts +1 -0
- package/src/responders/index.mts +4 -0
- package/src/responders/interfaces/error-responder.interface.mts +42 -0
- package/src/responders/interfaces/error-response.interface.mts +22 -0
- package/src/responders/interfaces/index.mts +3 -0
- package/src/responders/interfaces/problem-details.interface.mts +34 -0
- package/src/responders/services/error-response-producer.service.mts +143 -0
- package/src/responders/services/forbidden-responder.service.mts +77 -0
- package/src/responders/services/index.mts +5 -0
- package/src/responders/services/internal-server-error-responder.service.mts +57 -0
- package/src/responders/services/not-found-responder.service.mts +76 -0
- package/src/responders/services/validation-error-responder.service.mts +78 -0
- package/src/responders/tokens/index.mts +1 -0
- package/src/responders/tokens/responder.tokens.mts +84 -0
- package/src/services/guard-runner.service.mts +19 -6
- package/lib/index-B2ulzZIr.d.cts.map +0 -1
- package/lib/index-C8lUQePd.d.mts.map +0 -1
- package/lib/src-Baabu2R8.mjs.map +0 -1
- package/lib/src-Cu9OAnfp.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.0-alpha.1] - 2026-01-22
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **RFC 7807 Problem Details Error Responses**: New standardized error response system using RFC 7807 Problem Details format
|
|
13
|
+
- `ErrorResponseProducerService` - Central service for producing standardized error responses
|
|
14
|
+
- `FrameworkError` enum - Explicit error type specification (NotFound, Forbidden, InternalServerError, ValidationError)
|
|
15
|
+
- Customizable error responders with dependency injection support:
|
|
16
|
+
- `NotFoundResponderService` - Handles 404 Not Found errors
|
|
17
|
+
- `ForbiddenResponderService` - Handles 403 Forbidden errors (used by guards)
|
|
18
|
+
- `InternalServerErrorResponderService` - Handles 500 Internal Server errors
|
|
19
|
+
- `ValidationErrorResponderService` - Handles 400 Validation errors with structured Zod error details
|
|
20
|
+
- All responders registered with low priority (-10) for easy override
|
|
21
|
+
- `ErrorResponder` interface for custom responder implementations
|
|
22
|
+
- `ProblemDetails` interface following RFC 7807 specification
|
|
23
|
+
- `ErrorResponse` interface with status code, payload, and headers
|
|
24
|
+
- **Guard Error Handling Enhancement**: `GuardRunnerService` now uses `ErrorResponseProducerService` for standardized error responses
|
|
25
|
+
- Guard rejections now return RFC 7807 compliant responses
|
|
26
|
+
- Guard execution errors produce standardized internal server error responses
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **Error Response Format**: Error responses now use RFC 7807 Problem Details format instead of simple JSON
|
|
31
|
+
- Content-Type header set to `application/problem+json`
|
|
32
|
+
- Responses include `type`, `title`, `status`, and `detail` fields
|
|
33
|
+
- Validation errors include structured `errors` field with Zod validation details
|
|
34
|
+
- HttpException responses remain backward compatible (preserved original format)
|
|
35
|
+
|
|
36
|
+
### Breaking Changes
|
|
37
|
+
|
|
38
|
+
- **Error Response Format**: Non-HttpException errors now return RFC 7807 Problem Details format
|
|
39
|
+
- Previous format: `{ message: "..." }`
|
|
40
|
+
- New format: `{ type: "about:blank", title: "...", status: 404, detail: "..." }`
|
|
41
|
+
- HttpException responses are unchanged for backward compatibility
|
|
42
|
+
|
|
43
|
+
## [0.9.3] - 2026-01-05
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- **LegacyAttributeFactory Type Fix**: Fixed type definitions for `LegacyClassAttribute` and `LegacyClassSchemaAttribute` to properly support method decorators. Changed from complex function intersection types to simpler `ClassDecorator & MethodDecorator` types that TypeScript can correctly resolve.
|
|
48
|
+
|
|
8
49
|
## [0.9.2] - 2026-01-05
|
|
9
50
|
|
|
10
51
|
### Added
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ The adapter must be provided when creating your Navios application to define the
|
|
|
30
30
|
- **Build with Navios Builder**: Navios Builder is a powerful HTTP client that simplifies API requests. By combining it with Navios, you can use the same API definition for both the client and server, ensuring consistency and reducing duplication.
|
|
31
31
|
- **Declarative API**: The API is designed to be declarative, allowing you to define your API endpoints and their schemas in a clear and concise manner. This makes it easy to understand and maintain your API client.
|
|
32
32
|
- **Customizable**: The package allows you to customize the behavior of the API client, such as using a custom client.
|
|
33
|
-
- **Error Handling**: The package provides built-in error handling capabilities
|
|
33
|
+
- **Error Handling**: The package provides built-in error handling capabilities with RFC 7807 Problem Details format for standardized error responses. Includes customizable error responders and comprehensive exception handling.
|
|
34
34
|
|
|
35
35
|
## Adapters
|
|
36
36
|
|
package/docs/README.md
CHANGED
|
@@ -200,7 +200,7 @@ Choose the appropriate adapter based on your deployment environment and requirem
|
|
|
200
200
|
|
|
201
201
|
## Error Handling
|
|
202
202
|
|
|
203
|
-
Both adapters provide consistent error handling through Navios's exception system
|
|
203
|
+
Both adapters provide consistent error handling through Navios's exception system. Framework-level errors (validation errors, guard rejections, not found routes, unhandled errors) use **RFC 7807 Problem Details** format for standardized, machine-readable error responses. HttpException responses maintain backward compatibility with the original format.
|
|
204
204
|
|
|
205
205
|
```ts
|
|
206
206
|
import { BadRequestException, NotFoundException } from '@navios/core'
|
|
@@ -225,6 +225,8 @@ export class UserController {
|
|
|
225
225
|
}
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
+
For more information on error handling, including custom error responders and RFC 7807 Problem Details, see the [Error Handling Guide](../../../apps/docs/docs/server/guides/error-handling.md).
|
|
229
|
+
|
|
228
230
|
## Configuration
|
|
229
231
|
|
|
230
232
|
Both adapters support the same Navios configuration options:
|
package/docs/exceptions.md
CHANGED
|
@@ -168,7 +168,9 @@ export class UserController {
|
|
|
168
168
|
|
|
169
169
|
## Exception Response Format
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
### HttpException Response Format
|
|
172
|
+
|
|
173
|
+
`HttpException` and its subclasses (like `NotFoundException`, `BadRequestException`, etc.) maintain backward compatibility and return the original format:
|
|
172
174
|
|
|
173
175
|
```json
|
|
174
176
|
{
|
|
@@ -197,6 +199,40 @@ For exceptions with additional data:
|
|
|
197
199
|
}
|
|
198
200
|
```
|
|
199
201
|
|
|
202
|
+
### RFC 7807 Problem Details Format
|
|
203
|
+
|
|
204
|
+
Framework-level errors (validation errors, guard rejections, not found routes, unhandled errors) use **RFC 7807 Problem Details** format for standardized, machine-readable error responses:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"type": "about:blank",
|
|
209
|
+
"title": "Not Found",
|
|
210
|
+
"status": 404,
|
|
211
|
+
"detail": "Route [GET] /api/users/999 not found"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Validation errors include structured error details:
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"type": "about:blank",
|
|
220
|
+
"title": "Validation Error",
|
|
221
|
+
"status": 400,
|
|
222
|
+
"detail": "Request validation failed",
|
|
223
|
+
"errors": {
|
|
224
|
+
"email": {
|
|
225
|
+
"code": "invalid_string",
|
|
226
|
+
"validation": "email",
|
|
227
|
+
"message": "Invalid email",
|
|
228
|
+
"path": ["email"]
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
All Problem Details responses include the `Content-Type: application/problem+json` header. For more information on customizing error responders, see the [Error Handling Guide](../../../apps/docs/docs/server/guides/error-handling.md).
|
|
235
|
+
|
|
200
236
|
## Best Practices
|
|
201
237
|
|
|
202
238
|
### 1. Use Specific Exceptions
|
|
@@ -1660,6 +1660,448 @@ declare class ConflictException extends HttpException {
|
|
|
1660
1660
|
constructor(message: string | object, error?: Error);
|
|
1661
1661
|
}
|
|
1662
1662
|
//#endregion
|
|
1663
|
+
//#region src/responders/enums/framework-error.enum.d.mts
|
|
1664
|
+
/**
|
|
1665
|
+
* Enumeration of framework-level error types.
|
|
1666
|
+
* Used to explicitly specify which error responder should handle an error.
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* ```typescript
|
|
1670
|
+
* // In adapter error handling
|
|
1671
|
+
* if (error instanceof ZodError) {
|
|
1672
|
+
* return errorProducer.respond(FrameworkError.ValidationError, error)
|
|
1673
|
+
* }
|
|
1674
|
+
* return errorProducer.handleUnknown(error)
|
|
1675
|
+
* ```
|
|
1676
|
+
*/
|
|
1677
|
+
declare enum FrameworkError {
|
|
1678
|
+
/**
|
|
1679
|
+
* Resource not found (HTTP 404).
|
|
1680
|
+
* Use when a requested resource does not exist.
|
|
1681
|
+
*/
|
|
1682
|
+
NotFound = "NotFound",
|
|
1683
|
+
/**
|
|
1684
|
+
* Forbidden (HTTP 403).
|
|
1685
|
+
* Use when access to a resource is denied (e.g., guard rejection).
|
|
1686
|
+
*/
|
|
1687
|
+
Forbidden = "Forbidden",
|
|
1688
|
+
/**
|
|
1689
|
+
* Internal server error (HTTP 500).
|
|
1690
|
+
* Use for unexpected errors that don't fit other categories.
|
|
1691
|
+
*/
|
|
1692
|
+
InternalServerError = "InternalServerError",
|
|
1693
|
+
/**
|
|
1694
|
+
* Validation error (HTTP 400).
|
|
1695
|
+
* Use when request data fails validation (e.g., Zod errors).
|
|
1696
|
+
*/
|
|
1697
|
+
ValidationError = "ValidationError",
|
|
1698
|
+
}
|
|
1699
|
+
//#endregion
|
|
1700
|
+
//#region src/responders/interfaces/problem-details.interface.d.mts
|
|
1701
|
+
/**
|
|
1702
|
+
* RFC 7807 Problem Details for HTTP APIs
|
|
1703
|
+
* @see https://tools.ietf.org/html/rfc7807
|
|
1704
|
+
*/
|
|
1705
|
+
interface ProblemDetails {
|
|
1706
|
+
/**
|
|
1707
|
+
* A URI reference that identifies the problem type.
|
|
1708
|
+
* When dereferenced, it should provide human-readable documentation.
|
|
1709
|
+
* @default 'about:blank'
|
|
1710
|
+
*/
|
|
1711
|
+
type?: string;
|
|
1712
|
+
/**
|
|
1713
|
+
* A short, human-readable summary of the problem type.
|
|
1714
|
+
* It should not change from occurrence to occurrence.
|
|
1715
|
+
*/
|
|
1716
|
+
title: string;
|
|
1717
|
+
/**
|
|
1718
|
+
* The HTTP status code for this occurrence of the problem.
|
|
1719
|
+
*/
|
|
1720
|
+
status: number;
|
|
1721
|
+
/**
|
|
1722
|
+
* A human-readable explanation specific to this occurrence of the problem.
|
|
1723
|
+
*/
|
|
1724
|
+
detail?: string;
|
|
1725
|
+
/**
|
|
1726
|
+
* Additional extension members.
|
|
1727
|
+
* Custom properties can be added to provide more context.
|
|
1728
|
+
*/
|
|
1729
|
+
[key: string]: unknown;
|
|
1730
|
+
}
|
|
1731
|
+
//#endregion
|
|
1732
|
+
//#region src/responders/interfaces/error-response.interface.d.mts
|
|
1733
|
+
/**
|
|
1734
|
+
* Represents a complete error response that can be sent to the client.
|
|
1735
|
+
* Includes the status code, payload (RFC 7807 Problem Details), and headers.
|
|
1736
|
+
*/
|
|
1737
|
+
interface ErrorResponse {
|
|
1738
|
+
/**
|
|
1739
|
+
* HTTP status code for the response.
|
|
1740
|
+
*/
|
|
1741
|
+
statusCode: number;
|
|
1742
|
+
/**
|
|
1743
|
+
* RFC 7807 Problem Details payload.
|
|
1744
|
+
*/
|
|
1745
|
+
payload: ProblemDetails;
|
|
1746
|
+
/**
|
|
1747
|
+
* HTTP headers to include in the response.
|
|
1748
|
+
*/
|
|
1749
|
+
headers: Record<string, string>;
|
|
1750
|
+
}
|
|
1751
|
+
//#endregion
|
|
1752
|
+
//#region src/responders/interfaces/error-responder.interface.d.mts
|
|
1753
|
+
/**
|
|
1754
|
+
* Interface for error responders that convert errors to HTTP responses.
|
|
1755
|
+
* Each responder handles a specific type of framework error and produces
|
|
1756
|
+
* an RFC 7807 compliant response.
|
|
1757
|
+
*
|
|
1758
|
+
* Implementations are registered with low priority (-10) so they can be
|
|
1759
|
+
* easily overridden by consumers.
|
|
1760
|
+
*
|
|
1761
|
+
* @example
|
|
1762
|
+
* ```typescript
|
|
1763
|
+
* @Injectable({
|
|
1764
|
+
* token: InternalServerErrorResponderToken,
|
|
1765
|
+
* priority: 0, // Override default implementation
|
|
1766
|
+
* })
|
|
1767
|
+
* export class CustomInternalErrorResponder implements ErrorResponder {
|
|
1768
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1769
|
+
* return {
|
|
1770
|
+
* statusCode: 500,
|
|
1771
|
+
* payload: {
|
|
1772
|
+
* type: 'https://api.myapp.com/errors/server-error',
|
|
1773
|
+
* title: 'Server Error',
|
|
1774
|
+
* status: 500,
|
|
1775
|
+
* detail: description ?? 'An unexpected error occurred',
|
|
1776
|
+
* },
|
|
1777
|
+
* headers: { 'Content-Type': 'application/problem+json' },
|
|
1778
|
+
* }
|
|
1779
|
+
* }
|
|
1780
|
+
* }
|
|
1781
|
+
* ```
|
|
1782
|
+
*/
|
|
1783
|
+
interface ErrorResponder {
|
|
1784
|
+
/**
|
|
1785
|
+
* Converts an error to an ErrorResponse with RFC 7807 Problem Details.
|
|
1786
|
+
*
|
|
1787
|
+
* @param error - The original error that was thrown
|
|
1788
|
+
* @param description - Optional custom description to include in the response
|
|
1789
|
+
* @returns ErrorResponse with status code, payload, and headers
|
|
1790
|
+
*/
|
|
1791
|
+
getResponse(error: unknown, description?: string): ErrorResponse;
|
|
1792
|
+
}
|
|
1793
|
+
//#endregion
|
|
1794
|
+
//#region src/responders/services/error-response-producer.service.d.mts
|
|
1795
|
+
/**
|
|
1796
|
+
* Service for producing standardized error responses.
|
|
1797
|
+
*
|
|
1798
|
+
* This service coordinates error responders to produce RFC 7807 compliant
|
|
1799
|
+
* Problem Details responses. Adapters use this service to convert errors
|
|
1800
|
+
* into standardized HTTP responses.
|
|
1801
|
+
*
|
|
1802
|
+
* The caller explicitly specifies which type of error response to produce
|
|
1803
|
+
* via the FrameworkError enum, giving full control to the adapter.
|
|
1804
|
+
*
|
|
1805
|
+
* @example Usage in an adapter:
|
|
1806
|
+
* ```typescript
|
|
1807
|
+
* @Injectable()
|
|
1808
|
+
* class MyAdapter {
|
|
1809
|
+
* private errorProducer = inject(ErrorResponseProducerService)
|
|
1810
|
+
*
|
|
1811
|
+
* handleError(error: unknown): Response {
|
|
1812
|
+
* if (error instanceof ZodError) {
|
|
1813
|
+
* const response = this.errorProducer.respond(
|
|
1814
|
+
* FrameworkError.ValidationError,
|
|
1815
|
+
* error,
|
|
1816
|
+
* )
|
|
1817
|
+
* return new Response(JSON.stringify(response.payload), {
|
|
1818
|
+
* status: response.statusCode,
|
|
1819
|
+
* headers: response.headers,
|
|
1820
|
+
* })
|
|
1821
|
+
* }
|
|
1822
|
+
*
|
|
1823
|
+
* // Fallback for unknown errors
|
|
1824
|
+
* const response = this.errorProducer.handleUnknown(error)
|
|
1825
|
+
* return new Response(JSON.stringify(response.payload), {
|
|
1826
|
+
* status: response.statusCode,
|
|
1827
|
+
* headers: response.headers,
|
|
1828
|
+
* })
|
|
1829
|
+
* }
|
|
1830
|
+
* }
|
|
1831
|
+
* ```
|
|
1832
|
+
*/
|
|
1833
|
+
declare class ErrorResponseProducerService {
|
|
1834
|
+
private readonly forbiddenResponder;
|
|
1835
|
+
private readonly internalServerErrorResponder;
|
|
1836
|
+
private readonly notFoundResponder;
|
|
1837
|
+
private readonly validationErrorResponder;
|
|
1838
|
+
/**
|
|
1839
|
+
* Produces an error response for a specific framework error type.
|
|
1840
|
+
*
|
|
1841
|
+
* @param type - The type of framework error (from FrameworkError enum)
|
|
1842
|
+
* @param error - The original error that was thrown
|
|
1843
|
+
* @param description - Optional custom description to include in the response
|
|
1844
|
+
* @returns ErrorResponse with status code, RFC 7807 payload, and headers
|
|
1845
|
+
*/
|
|
1846
|
+
respond(type: FrameworkError, error: unknown, description?: string): ErrorResponse;
|
|
1847
|
+
/**
|
|
1848
|
+
* Handles unknown errors by producing an Internal Server Error response.
|
|
1849
|
+
*
|
|
1850
|
+
* Use this as a fallback when the error type is not known or doesn't
|
|
1851
|
+
* match any specific framework error type.
|
|
1852
|
+
*
|
|
1853
|
+
* @param error - The original error that was thrown
|
|
1854
|
+
* @param description - Optional custom description to include in the response
|
|
1855
|
+
* @returns ErrorResponse with 500 status code
|
|
1856
|
+
*/
|
|
1857
|
+
handleUnknown(error: unknown, description?: string): ErrorResponse;
|
|
1858
|
+
/**
|
|
1859
|
+
* Convenience method to produce a Not Found error response.
|
|
1860
|
+
*
|
|
1861
|
+
* @param error - The original error that was thrown
|
|
1862
|
+
* @param description - Optional custom description
|
|
1863
|
+
* @returns ErrorResponse with 404 status code
|
|
1864
|
+
*/
|
|
1865
|
+
notFound(error: unknown, description?: string): ErrorResponse;
|
|
1866
|
+
/**
|
|
1867
|
+
* Convenience method to produce a Validation Error response.
|
|
1868
|
+
*
|
|
1869
|
+
* @param error - The original error (typically a ZodError)
|
|
1870
|
+
* @param description - Optional custom description
|
|
1871
|
+
* @returns ErrorResponse with 400 status code
|
|
1872
|
+
*/
|
|
1873
|
+
validationError(error: unknown, description?: string): ErrorResponse;
|
|
1874
|
+
/**
|
|
1875
|
+
* Convenience method to produce an Internal Server Error response.
|
|
1876
|
+
*
|
|
1877
|
+
* @param error - The original error
|
|
1878
|
+
* @param description - Optional custom description
|
|
1879
|
+
* @returns ErrorResponse with 500 status code
|
|
1880
|
+
*/
|
|
1881
|
+
internalServerError(error: unknown, description?: string): ErrorResponse;
|
|
1882
|
+
/**
|
|
1883
|
+
* Convenience method to produce a Forbidden error response.
|
|
1884
|
+
*
|
|
1885
|
+
* @param error - The original error
|
|
1886
|
+
* @param description - Optional custom description
|
|
1887
|
+
* @returns ErrorResponse with 403 status code
|
|
1888
|
+
*/
|
|
1889
|
+
forbidden(error: unknown, description?: string): ErrorResponse;
|
|
1890
|
+
}
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region src/responders/services/forbidden-responder.service.d.mts
|
|
1893
|
+
/**
|
|
1894
|
+
* Default responder for forbidden errors (HTTP 403).
|
|
1895
|
+
*
|
|
1896
|
+
* Converts errors to RFC 7807 Problem Details format.
|
|
1897
|
+
* Used when access to a resource is denied (e.g., guard rejection).
|
|
1898
|
+
* Registered with low priority (-10) so it can be easily overridden.
|
|
1899
|
+
*
|
|
1900
|
+
* @example Override with custom implementation:
|
|
1901
|
+
* ```typescript
|
|
1902
|
+
* @Injectable({
|
|
1903
|
+
* token: ForbiddenResponderToken,
|
|
1904
|
+
* priority: 0,
|
|
1905
|
+
* })
|
|
1906
|
+
* export class CustomForbiddenResponder implements ErrorResponder {
|
|
1907
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1908
|
+
* return {
|
|
1909
|
+
* statusCode: 403,
|
|
1910
|
+
* payload: {
|
|
1911
|
+
* type: 'https://api.myapp.com/errors/forbidden',
|
|
1912
|
+
* title: 'Access Denied',
|
|
1913
|
+
* status: 403,
|
|
1914
|
+
* detail: description ?? 'You do not have permission to access this resource',
|
|
1915
|
+
* },
|
|
1916
|
+
* headers: { 'Content-Type': 'application/problem+json' },
|
|
1917
|
+
* }
|
|
1918
|
+
* }
|
|
1919
|
+
* }
|
|
1920
|
+
* ```
|
|
1921
|
+
*/
|
|
1922
|
+
declare class ForbiddenResponderService implements ErrorResponder {
|
|
1923
|
+
getResponse(error: unknown, description?: string): ErrorResponse;
|
|
1924
|
+
private createResponse;
|
|
1925
|
+
}
|
|
1926
|
+
//#endregion
|
|
1927
|
+
//#region src/responders/services/internal-server-error-responder.service.d.mts
|
|
1928
|
+
/**
|
|
1929
|
+
* Default responder for internal server errors (HTTP 500).
|
|
1930
|
+
*
|
|
1931
|
+
* Converts generic errors to RFC 7807 Problem Details format.
|
|
1932
|
+
* Registered with low priority (-10) so it can be easily overridden.
|
|
1933
|
+
*
|
|
1934
|
+
* @example Override with custom implementation:
|
|
1935
|
+
* ```typescript
|
|
1936
|
+
* @Injectable({
|
|
1937
|
+
* token: InternalServerErrorResponderToken,
|
|
1938
|
+
* priority: 0,
|
|
1939
|
+
* })
|
|
1940
|
+
* export class CustomInternalErrorResponder implements ErrorResponder {
|
|
1941
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1942
|
+
* return {
|
|
1943
|
+
* statusCode: 500,
|
|
1944
|
+
* payload: {
|
|
1945
|
+
* type: 'https://api.myapp.com/errors/server-error',
|
|
1946
|
+
* title: 'Server Error',
|
|
1947
|
+
* status: 500,
|
|
1948
|
+
* detail: description ?? 'An unexpected error occurred',
|
|
1949
|
+
* },
|
|
1950
|
+
* headers: { 'Content-Type': 'application/problem+json' },
|
|
1951
|
+
* }
|
|
1952
|
+
* }
|
|
1953
|
+
* }
|
|
1954
|
+
* ```
|
|
1955
|
+
*/
|
|
1956
|
+
declare class InternalServerErrorResponderService implements ErrorResponder {
|
|
1957
|
+
getResponse(error: unknown, description?: string): ErrorResponse;
|
|
1958
|
+
}
|
|
1959
|
+
//#endregion
|
|
1960
|
+
//#region src/responders/services/not-found-responder.service.d.mts
|
|
1961
|
+
/**
|
|
1962
|
+
* Default responder for not found errors (HTTP 404).
|
|
1963
|
+
*
|
|
1964
|
+
* Converts errors to RFC 7807 Problem Details format.
|
|
1965
|
+
* Registered with low priority (-10) so it can be easily overridden.
|
|
1966
|
+
*
|
|
1967
|
+
* @example Override with custom implementation:
|
|
1968
|
+
* ```typescript
|
|
1969
|
+
* @Injectable({
|
|
1970
|
+
* token: NotFoundResponderToken,
|
|
1971
|
+
* priority: 0,
|
|
1972
|
+
* })
|
|
1973
|
+
* export class CustomNotFoundResponder implements ErrorResponder {
|
|
1974
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
1975
|
+
* return {
|
|
1976
|
+
* statusCode: 404,
|
|
1977
|
+
* payload: {
|
|
1978
|
+
* type: 'https://api.myapp.com/errors/not-found',
|
|
1979
|
+
* title: 'Resource Not Found',
|
|
1980
|
+
* status: 404,
|
|
1981
|
+
* detail: description ?? 'The requested resource was not found',
|
|
1982
|
+
* },
|
|
1983
|
+
* headers: { 'Content-Type': 'application/problem+json' },
|
|
1984
|
+
* }
|
|
1985
|
+
* }
|
|
1986
|
+
* }
|
|
1987
|
+
* ```
|
|
1988
|
+
*/
|
|
1989
|
+
declare class NotFoundResponderService implements ErrorResponder {
|
|
1990
|
+
getResponse(error: unknown, description?: string): ErrorResponse;
|
|
1991
|
+
private createResponse;
|
|
1992
|
+
}
|
|
1993
|
+
//#endregion
|
|
1994
|
+
//#region src/responders/services/validation-error-responder.service.d.mts
|
|
1995
|
+
/**
|
|
1996
|
+
* Default responder for validation errors (HTTP 400).
|
|
1997
|
+
*
|
|
1998
|
+
* Converts Zod validation errors to RFC 7807 Problem Details format.
|
|
1999
|
+
* Includes the structured validation errors from treeifyError.
|
|
2000
|
+
* Registered with low priority (-10) so it can be easily overridden.
|
|
2001
|
+
*
|
|
2002
|
+
* @example Override with custom implementation:
|
|
2003
|
+
* ```typescript
|
|
2004
|
+
* @Injectable({
|
|
2005
|
+
* token: ValidationErrorResponderToken,
|
|
2006
|
+
* priority: 0,
|
|
2007
|
+
* })
|
|
2008
|
+
* export class CustomValidationResponder implements ErrorResponder {
|
|
2009
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
2010
|
+
* const zodError = error as ZodError
|
|
2011
|
+
* return {
|
|
2012
|
+
* statusCode: 422, // Use 422 instead of 400
|
|
2013
|
+
* payload: {
|
|
2014
|
+
* type: 'https://api.myapp.com/errors/validation',
|
|
2015
|
+
* title: 'Unprocessable Entity',
|
|
2016
|
+
* status: 422,
|
|
2017
|
+
* detail: description ?? 'Validation failed',
|
|
2018
|
+
* issues: zodError.issues,
|
|
2019
|
+
* },
|
|
2020
|
+
* headers: { 'Content-Type': 'application/problem+json' },
|
|
2021
|
+
* }
|
|
2022
|
+
* }
|
|
2023
|
+
* }
|
|
2024
|
+
* ```
|
|
2025
|
+
*/
|
|
2026
|
+
declare class ValidationErrorResponderService implements ErrorResponder {
|
|
2027
|
+
getResponse(error: unknown, description?: string): ErrorResponse;
|
|
2028
|
+
}
|
|
2029
|
+
//#endregion
|
|
2030
|
+
//#region src/responders/tokens/responder.tokens.d.mts
|
|
2031
|
+
/**
|
|
2032
|
+
* Injection token for the Internal Server Error responder.
|
|
2033
|
+
* Default implementation returns HTTP 500 with RFC 7807 Problem Details.
|
|
2034
|
+
*
|
|
2035
|
+
* @example Override with custom implementation:
|
|
2036
|
+
* ```typescript
|
|
2037
|
+
* @Injectable({
|
|
2038
|
+
* token: InternalServerErrorResponderToken,
|
|
2039
|
+
* priority: 0, // Higher than default -10
|
|
2040
|
+
* })
|
|
2041
|
+
* export class CustomInternalErrorResponder implements ErrorResponder {
|
|
2042
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
2043
|
+
* // Custom implementation
|
|
2044
|
+
* }
|
|
2045
|
+
* }
|
|
2046
|
+
* ```
|
|
2047
|
+
*/
|
|
2048
|
+
declare const InternalServerErrorResponderToken: InjectionToken<ErrorResponder, undefined, false>;
|
|
2049
|
+
/**
|
|
2050
|
+
* Injection token for the Not Found responder.
|
|
2051
|
+
* Default implementation returns HTTP 404 with RFC 7807 Problem Details.
|
|
2052
|
+
*
|
|
2053
|
+
* @example Override with custom implementation:
|
|
2054
|
+
* ```typescript
|
|
2055
|
+
* @Injectable({
|
|
2056
|
+
* token: NotFoundResponderToken,
|
|
2057
|
+
* priority: 0, // Higher than default -10
|
|
2058
|
+
* })
|
|
2059
|
+
* export class CustomNotFoundResponder implements ErrorResponder {
|
|
2060
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
2061
|
+
* // Custom implementation
|
|
2062
|
+
* }
|
|
2063
|
+
* }
|
|
2064
|
+
* ```
|
|
2065
|
+
*/
|
|
2066
|
+
declare const NotFoundResponderToken: InjectionToken<ErrorResponder, undefined, false>;
|
|
2067
|
+
/**
|
|
2068
|
+
* Injection token for the Validation Error responder.
|
|
2069
|
+
* Default implementation returns HTTP 400 with RFC 7807 Problem Details
|
|
2070
|
+
* and includes validation errors from ZodError.
|
|
2071
|
+
*
|
|
2072
|
+
* @example Override with custom implementation:
|
|
2073
|
+
* ```typescript
|
|
2074
|
+
* @Injectable({
|
|
2075
|
+
* token: ValidationErrorResponderToken,
|
|
2076
|
+
* priority: 0, // Higher than default -10
|
|
2077
|
+
* })
|
|
2078
|
+
* export class CustomValidationResponder implements ErrorResponder {
|
|
2079
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
2080
|
+
* // Custom implementation
|
|
2081
|
+
* }
|
|
2082
|
+
* }
|
|
2083
|
+
* ```
|
|
2084
|
+
*/
|
|
2085
|
+
declare const ValidationErrorResponderToken: InjectionToken<ErrorResponder, undefined, false>;
|
|
2086
|
+
/**
|
|
2087
|
+
* Injection token for the Forbidden responder.
|
|
2088
|
+
* Default implementation returns HTTP 403 with RFC 7807 Problem Details.
|
|
2089
|
+
*
|
|
2090
|
+
* @example Override with custom implementation:
|
|
2091
|
+
* ```typescript
|
|
2092
|
+
* @Injectable({
|
|
2093
|
+
* token: ForbiddenResponderToken,
|
|
2094
|
+
* priority: 0, // Higher than default -10
|
|
2095
|
+
* })
|
|
2096
|
+
* export class CustomForbiddenResponder implements ErrorResponder {
|
|
2097
|
+
* getResponse(error: unknown, description?: string): ErrorResponse {
|
|
2098
|
+
* // Custom implementation
|
|
2099
|
+
* }
|
|
2100
|
+
* }
|
|
2101
|
+
* ```
|
|
2102
|
+
*/
|
|
2103
|
+
declare const ForbiddenResponderToken: InjectionToken<ErrorResponder, undefined, false>;
|
|
2104
|
+
//#endregion
|
|
1663
2105
|
//#region src/services/instance-resolver.service.d.mts
|
|
1664
2106
|
/**
|
|
1665
2107
|
* Result of instance resolution attempt.
|
|
@@ -1769,6 +2211,7 @@ type ControllerResolution<T = any> = InstanceResolution<T>;
|
|
|
1769
2211
|
//#endregion
|
|
1770
2212
|
//#region src/services/guard-runner.service.d.mts
|
|
1771
2213
|
declare class GuardRunnerService {
|
|
2214
|
+
private readonly errorProducer;
|
|
1772
2215
|
private readonly logger;
|
|
1773
2216
|
/**
|
|
1774
2217
|
* Runs guards that need to be resolved from a scoped container.
|
|
@@ -2373,5 +2816,5 @@ declare class NaviosFactory {
|
|
|
2373
2816
|
private static registerLoggerConfiguration;
|
|
2374
2817
|
}
|
|
2375
2818
|
//#endregion
|
|
2376
|
-
export {
|
|
2377
|
-
//# sourceMappingURL=index-
|
|
2819
|
+
export { HttpException as $, yellow as $t, ControllerResolverService as A, ConfigServiceToken as An, LoggerInstance as At, InternalServerErrorResponderService as B, isObject as Bt, EndpointAdapterToken as C, ControllerOptions as Cn, AbstractHttpAdapterInterface as Ct, setRequestIdEnabled as D, ConfigService as Dn, LoggerOptions as Dt, runWithRequestId as E, provideConfig as En, Logger as Et, InternalServerErrorResponderToken as F, PathValue as Fn, isConstructor as Ft, ProblemDetails as G, normalizePath as Gt, ErrorResponseProducerService as H, isString as Ht, NotFoundResponderToken as I, envInt as In, isEmpty as It, UnauthorizedException as J, isLogLevel as Jt, FrameworkError as K, stripEndSlash as Kt, ValidationErrorResponderToken as L, envString as Ln, isFunction as Lt, InstanceResolverService as M, Path as Mn, ConsoleLoggerOptions as Mt, MultiInstanceResolution as N, PathImpl as Nn, LoggerService as Nt, GuardRunnerService as O, ConfigServiceOptions as On, LoggerOutput as Ot, ForbiddenResponderToken as P, PathImpl2 as Pn, addLeadingSlash as Pt, BadRequestException as Q, clc as Qt, ValidationErrorResponderService as R, isNil as Rt, ExecutionContextInjectionToken as S, Controller as Sn, StaticHandler as St, getRequestId as T, EnvConfigProvider as Tn, AbstractHttpCorsOptions as Tt, ErrorResponder as U, isSymbol as Ut, ForbiddenResponderService as V, isPlainObject as Vt, ErrorResponse as W, isUndefined as Wt, InternalServerErrorException as X, LOG_LEVELS as Xt, NotFoundException as Y, filterLogLevels as Yt, ForbiddenException as Z, LogLevel as Zt, NaviosApplication as _, getAllEndpointMetadata as _n, OmitIndexSignature as _t, RequestFactory as a, ModuleMetadata as an, MultipartResult as at, HttpAdapterToken as b, EndpointParams as bn, DynamicHandler as bt, EndpointAdapterFactory as c, getModuleMetadata as cn, HttpCode as ct, ClassSchemaAttribute as d, ControllerMetadataKey as dn, PluginContext as dt, AbstractExecutionContext as en, UseGuards as et, XmlStreamAdapterToken as f, extractControllerMetadata as fn, PluginDefinition as ft, NaviosOptionsToken as g, HandlerMetadata as gn, HttpHeader as gt, Reply as h, EndpointMetadataKey as hn, NaviosModule as ht, ReplyFactory as i, hasManagedMetadata as in, MultipartParams as it, InstanceResolution as j, ConfigServiceInterface as jn, ConsoleLogger as jt, ControllerResolution as k, ConfigServiceOptionsSchema as kn, loggerOptionsSchema as kt, AttributeFactory as l, hasModuleMetadata as ln, Header as lt, Request as m, hasControllerMetadata as mn, ModuleLoaderService as mt, XmlStreamAdapterFactory as n, NaviosManagedMetadataKey as nn, StreamParams as nt, MultipartAdapterFactory as o, ModuleMetadataKey as on, Module as ot, StreamAdapterToken as p, getControllerMetadata as pn, ModuleExtension as pt, ConflictException as q, isLogLevelEnabled as qt, StreamAdapterFactory as r, getManagedMetadata as rn, Multipart as rt, HttpAdapterFactory as s, extractModuleMetadata as sn, ModuleOptions as st, NaviosFactory as t, ManagedMetadata as tn, Stream as tt, ClassAttribute as u, ControllerMetadata as un, NaviosPlugin as ut, NaviosApplicationOptions as v, getEndpointMetadata as vn, CanActivate as vt, generateRequestId as w, ConfigProviderOptions as wn, AbstractHttpListenOptions as wt, ExecutionContext as x, EndpointResult as xn, HandlerResult as xt, MultipartAdapterToken as y, Endpoint as yn, AbstractHttpHandlerAdapterInterface as yt, NotFoundResponderService as z, isNumber as zt };
|
|
2820
|
+
//# sourceMappingURL=index-BOBeqs9U.d.cts.map
|