@decaf-ts/for-nest 0.6.0 → 0.7.0
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/lib/cjs/bin/cli.cjs +3 -2
- package/lib/cjs/bin/cli.cjs.map +1 -0
- package/lib/cjs/cli-module.cjs +2 -1
- package/lib/cjs/cli-module.cjs.map +1 -0
- package/lib/cjs/constants.cjs +1 -0
- package/lib/cjs/constants.cjs.map +1 -0
- package/lib/cjs/controllers.cjs +3 -2
- package/lib/cjs/controllers.cjs.map +1 -0
- package/lib/cjs/core-module.cjs +31 -25
- package/lib/cjs/core-module.cjs.map +1 -0
- package/lib/cjs/decaf-model/DecafModelModule.cjs +11 -6
- package/lib/cjs/decaf-model/DecafModelModule.cjs.map +1 -0
- package/lib/cjs/decaf-model/FromModelController.cjs +69 -63
- package/lib/cjs/decaf-model/FromModelController.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/decorators.cjs +5 -4
- package/lib/cjs/decaf-model/decorators/decorators.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/index.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/index.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/types.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/types.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/utils.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/utils.cjs.map +1 -0
- package/lib/cjs/decaf-model/index.cjs +1 -0
- package/lib/cjs/decaf-model/index.cjs.map +1 -0
- package/lib/cjs/decaf-model/types.cjs +1 -0
- package/lib/cjs/decaf-model/types.cjs.map +1 -0
- package/lib/cjs/decaf-model/utils.cjs +5 -4
- package/lib/cjs/decaf-model/utils.cjs.map +1 -0
- package/lib/cjs/decoration.cjs +15 -14
- package/lib/cjs/decoration.cjs.map +1 -0
- package/lib/cjs/events-module/DecafStreamModule.cjs +15 -10
- package/lib/cjs/events-module/DecafStreamModule.cjs.map +1 -0
- package/lib/cjs/events-module/EventsController.cjs +20 -14
- package/lib/cjs/events-module/EventsController.cjs.map +1 -0
- package/lib/cjs/events-module/constant.cjs +1 -0
- package/lib/cjs/events-module/constant.cjs.map +1 -0
- package/lib/cjs/events-module/index.cjs +1 -0
- package/lib/cjs/events-module/index.cjs.map +1 -0
- package/lib/cjs/events-module/utils.cjs +1 -0
- package/lib/cjs/events-module/utils.cjs.map +1 -0
- package/lib/cjs/factory/NestBootstraper.cjs +7 -6
- package/lib/cjs/factory/NestBootstraper.cjs.map +1 -0
- package/lib/cjs/factory/errors/cors.cjs +1 -0
- package/lib/cjs/factory/errors/cors.cjs.map +1 -0
- package/lib/cjs/factory/errors/index.cjs +1 -0
- package/lib/cjs/factory/errors/index.cjs.map +1 -0
- package/lib/cjs/factory/errors/throttling.cjs +1 -0
- package/lib/cjs/factory/errors/throttling.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs +11 -6
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/decorators.cjs +5 -4
- package/lib/cjs/factory/exceptions/decorators.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/index.cjs +1 -0
- package/lib/cjs/factory/exceptions/index.cjs.map +1 -0
- package/lib/cjs/factory/index.cjs +1 -0
- package/lib/cjs/factory/index.cjs.map +1 -0
- package/lib/cjs/factory/openapi/DtoBuilder.cjs +8 -7
- package/lib/cjs/factory/openapi/DtoBuilder.cjs.map +1 -0
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs +7 -6
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs.map +1 -0
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs +3 -2
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs.map +1 -0
- package/lib/cjs/factory/openapi/constants.cjs +1 -0
- package/lib/cjs/factory/openapi/constants.cjs.map +1 -0
- package/lib/cjs/factory/openapi/index.cjs +1 -0
- package/lib/cjs/factory/openapi/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +18 -17
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/interceptors/AuthInterceptor.cjs +16 -10
- package/lib/cjs/interceptors/AuthInterceptor.cjs.map +1 -0
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs +14 -8
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs.map +1 -0
- package/lib/cjs/interceptors/context.cjs +1 -0
- package/lib/cjs/interceptors/context.cjs.map +1 -0
- package/lib/cjs/interceptors/index.cjs +1 -0
- package/lib/cjs/interceptors/index.cjs.map +1 -0
- package/lib/cjs/module.cjs +16 -11
- package/lib/cjs/module.cjs.map +1 -0
- package/lib/cjs/overrides/Adapter.cjs +1 -0
- package/lib/cjs/overrides/Adapter.cjs.map +1 -0
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs +3 -2
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs.map +1 -0
- package/lib/cjs/overrides/constants.cjs +1 -0
- package/lib/cjs/overrides/constants.cjs.map +1 -0
- package/lib/cjs/overrides/decoration.cjs +8 -7
- package/lib/cjs/overrides/decoration.cjs.map +1 -0
- package/lib/cjs/overrides/helpers.cjs +8 -7
- package/lib/cjs/overrides/helpers.cjs.map +1 -0
- package/lib/cjs/overrides/index.cjs +1 -0
- package/lib/cjs/overrides/index.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +1 -0
- package/lib/cjs/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/ram/RamRequestTransformer.cjs +1 -0
- package/lib/cjs/ram/RamRequestTransformer.cjs.map +1 -0
- package/lib/cjs/ram/index.cjs +1 -0
- package/lib/cjs/ram/index.cjs.map +1 -0
- package/lib/cjs/request/DecafAuthHandler.cjs +1 -0
- package/lib/cjs/request/DecafAuthHandler.cjs.map +1 -0
- package/lib/cjs/request/DecafHandlerExecutor.cjs +16 -10
- package/lib/cjs/request/DecafHandlerExecutor.cjs.map +1 -0
- package/lib/cjs/request/DecafRequestContext.cjs +12 -6
- package/lib/cjs/request/DecafRequestContext.cjs.map +1 -0
- package/lib/cjs/request/DecafResponseInterceptor.cjs +13 -7
- package/lib/cjs/request/DecafResponseInterceptor.cjs.map +1 -0
- package/lib/cjs/request/index.cjs +1 -0
- package/lib/cjs/request/index.cjs.map +1 -0
- package/lib/cjs/types.cjs +1 -0
- package/lib/cjs/types.cjs.map +1 -0
- package/lib/cjs/utils.cjs +1 -0
- package/lib/cjs/utils.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/bin/cli.d.cts +1 -0
- package/lib/types/bin/cli.d.mts +1 -0
- package/lib/types/cli-module.d.cts +11 -0
- package/lib/types/cli-module.d.mts +11 -0
- package/lib/types/constants.d.cts +15 -0
- package/lib/types/constants.d.mts +15 -0
- package/lib/types/controllers.d.cts +22 -0
- package/lib/types/controllers.d.mts +22 -0
- package/lib/types/core-module.d.cts +17 -0
- package/lib/types/core-module.d.mts +17 -0
- package/lib/types/decaf-model/DecafModelModule.d.cts +9 -0
- package/lib/types/decaf-model/DecafModelModule.d.mts +9 -0
- package/lib/types/decaf-model/FromModelController.d.cts +61 -0
- package/lib/types/decaf-model/FromModelController.d.mts +61 -0
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.cts +30 -0
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.mts +30 -0
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.cts +13 -0
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.mts +13 -0
- package/lib/types/decaf-model/decorators/DecafBody.d.cts +5 -0
- package/lib/types/decaf-model/decorators/DecafBody.d.mts +5 -0
- package/lib/types/decaf-model/decorators/DecafParams.d.cts +9 -0
- package/lib/types/decaf-model/decorators/DecafParams.d.mts +9 -0
- package/lib/types/decaf-model/decorators/decorators.d.cts +29 -0
- package/lib/types/decaf-model/decorators/decorators.d.mts +29 -0
- package/lib/types/decaf-model/decorators/index.d.cts +7 -0
- package/lib/types/decaf-model/decorators/index.d.mts +7 -0
- package/lib/types/decaf-model/decorators/types.d.cts +23 -0
- package/lib/types/decaf-model/decorators/types.d.mts +23 -0
- package/lib/types/decaf-model/decorators/utils.d.cts +11 -0
- package/lib/types/decaf-model/decorators/utils.d.mts +11 -0
- package/lib/types/decaf-model/index.d.cts +3 -0
- package/lib/types/decaf-model/index.d.mts +3 -0
- package/lib/types/decaf-model/types.d.cts +7 -0
- package/lib/types/decaf-model/types.d.mts +7 -0
- package/lib/types/decaf-model/utils.d.cts +10 -0
- package/lib/types/decaf-model/utils.d.mts +10 -0
- package/lib/types/decoration.d.cts +1 -0
- package/lib/types/decoration.d.mts +1 -0
- package/lib/types/events-module/DecafStreamModule.d.cts +4 -0
- package/lib/types/events-module/DecafStreamModule.d.mts +4 -0
- package/lib/types/events-module/EventsController.d.cts +11 -0
- package/lib/types/events-module/EventsController.d.mts +11 -0
- package/lib/types/events-module/constant.d.cts +1 -0
- package/lib/types/events-module/constant.d.mts +1 -0
- package/lib/types/events-module/index.d.cts +2 -0
- package/lib/types/events-module/index.d.mts +2 -0
- package/lib/types/events-module/utils.d.cts +1 -0
- package/lib/types/events-module/utils.d.mts +1 -0
- package/lib/types/factory/NestBootstraper.d.cts +224 -0
- package/lib/types/factory/NestBootstraper.d.mts +224 -0
- package/lib/types/factory/errors/cors.d.cts +4 -0
- package/lib/types/factory/errors/cors.d.mts +4 -0
- package/lib/types/factory/errors/index.d.cts +1 -0
- package/lib/types/factory/errors/index.d.mts +1 -0
- package/lib/types/factory/errors/throttling.d.cts +4 -0
- package/lib/types/factory/errors/throttling.d.mts +4 -0
- package/lib/types/factory/exceptions/DecafErrorFilter.d.cts +4 -0
- package/lib/types/factory/exceptions/DecafErrorFilter.d.mts +4 -0
- package/lib/types/factory/exceptions/decorators.d.cts +2 -0
- package/lib/types/factory/exceptions/decorators.d.mts +2 -0
- package/lib/types/factory/exceptions/index.d.cts +2 -0
- package/lib/types/factory/exceptions/index.d.mts +2 -0
- package/lib/types/factory/index.d.cts +4 -0
- package/lib/types/factory/index.d.mts +4 -0
- package/lib/types/factory/openapi/DtoBuilder.d.cts +25 -0
- package/lib/types/factory/openapi/DtoBuilder.d.mts +25 -0
- package/lib/types/factory/openapi/SwaggerBuilder.d.cts +10 -0
- package/lib/types/factory/openapi/SwaggerBuilder.d.mts +10 -0
- package/lib/types/factory/openapi/SwaggerCustomUI.d.cts +22 -0
- package/lib/types/factory/openapi/SwaggerCustomUI.d.mts +22 -0
- package/lib/types/factory/openapi/constants.d.cts +27 -0
- package/lib/types/factory/openapi/constants.d.mts +27 -0
- package/lib/types/factory/openapi/index.d.cts +2 -0
- package/lib/types/factory/openapi/index.d.mts +2 -0
- package/lib/types/index.d.cts +43 -0
- package/lib/types/index.d.mts +43 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interceptors/AuthInterceptor.d.cts +10 -0
- package/lib/types/interceptors/AuthInterceptor.d.mts +10 -0
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.cts +57 -0
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.mts +57 -0
- package/lib/types/interceptors/context.d.cts +6 -0
- package/lib/types/interceptors/context.d.mts +6 -0
- package/lib/types/interceptors/index.d.cts +3 -0
- package/lib/types/interceptors/index.d.mts +3 -0
- package/lib/types/module.d.cts +8 -0
- package/lib/types/module.d.mts +8 -0
- package/lib/types/overrides/Adapter.d.cts +13 -0
- package/lib/types/overrides/Adapter.d.mts +13 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.cts +8 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.mts +8 -0
- package/lib/types/overrides/constants.d.cts +21 -0
- package/lib/types/overrides/constants.d.mts +21 -0
- package/lib/types/overrides/decoration.d.cts +30 -0
- package/lib/types/overrides/decoration.d.mts +30 -0
- package/lib/types/overrides/helpers.d.cts +11 -0
- package/lib/types/overrides/helpers.d.mts +11 -0
- package/lib/types/overrides/index.d.cts +6 -0
- package/lib/types/overrides/index.d.mts +6 -0
- package/lib/types/overrides/overrides.d.cts +1 -0
- package/lib/types/overrides/overrides.d.mts +1 -0
- package/lib/types/ram/RamRequestTransformer.d.cts +5 -0
- package/lib/types/ram/RamRequestTransformer.d.mts +5 -0
- package/lib/types/ram/index.d.cts +1 -0
- package/lib/types/ram/index.d.mts +1 -0
- package/lib/types/request/DecafAuthHandler.d.cts +10 -0
- package/lib/types/request/DecafAuthHandler.d.mts +10 -0
- package/lib/types/request/DecafHandlerExecutor.d.cts +52 -0
- package/lib/types/request/DecafHandlerExecutor.d.mts +52 -0
- package/lib/types/request/DecafRequestContext.d.cts +11 -0
- package/lib/types/request/DecafRequestContext.d.mts +11 -0
- package/lib/types/request/DecafResponseInterceptor.d.cts +8 -0
- package/lib/types/request/DecafResponseInterceptor.d.mts +8 -0
- package/lib/types/request/index.d.cts +4 -0
- package/lib/types/request/index.d.mts +4 -0
- package/lib/types/types.d.cts +88 -0
- package/lib/types/types.d.mts +88 -0
- package/lib/types/utils.d.cts +2 -0
- package/lib/types/utils.d.mts +2 -0
- package/package.json +4 -4
- package/lib/cjs/bin/cli.js.map +0 -1
- package/lib/cjs/cli-module.js.map +0 -1
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/controllers.js.map +0 -1
- package/lib/cjs/core-module.js.map +0 -1
- package/lib/cjs/decaf-model/DecafModelModule.js.map +0 -1
- package/lib/cjs/decaf-model/FromModelController.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/DecafBody.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/DecafParams.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/decorators.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/index.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/types.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/utils.js.map +0 -1
- package/lib/cjs/decaf-model/index.js.map +0 -1
- package/lib/cjs/decaf-model/types.js.map +0 -1
- package/lib/cjs/decaf-model/utils.js.map +0 -1
- package/lib/cjs/decoration.js.map +0 -1
- package/lib/cjs/events-module/DecafStreamModule.js.map +0 -1
- package/lib/cjs/events-module/EventsController.js.map +0 -1
- package/lib/cjs/events-module/constant.js.map +0 -1
- package/lib/cjs/events-module/index.js.map +0 -1
- package/lib/cjs/events-module/utils.js.map +0 -1
- package/lib/cjs/factory/NestBootstraper.js.map +0 -1
- package/lib/cjs/factory/errors/cors.js.map +0 -1
- package/lib/cjs/factory/errors/index.js.map +0 -1
- package/lib/cjs/factory/errors/throttling.js.map +0 -1
- package/lib/cjs/factory/exceptions/DecafErrorFilter.js.map +0 -1
- package/lib/cjs/factory/exceptions/decorators.js.map +0 -1
- package/lib/cjs/factory/exceptions/index.js.map +0 -1
- package/lib/cjs/factory/index.js.map +0 -1
- package/lib/cjs/factory/openapi/DtoBuilder.js.map +0 -1
- package/lib/cjs/factory/openapi/SwaggerBuilder.js.map +0 -1
- package/lib/cjs/factory/openapi/SwaggerCustomUI.js.map +0 -1
- package/lib/cjs/factory/openapi/constants.js.map +0 -1
- package/lib/cjs/factory/openapi/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interceptors/AuthInterceptor.js.map +0 -1
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.js.map +0 -1
- package/lib/cjs/interceptors/context.js.map +0 -1
- package/lib/cjs/interceptors/index.js.map +0 -1
- package/lib/cjs/module.js.map +0 -1
- package/lib/cjs/overrides/Adapter.js.map +0 -1
- package/lib/cjs/overrides/ModelBuilderExtensions.js.map +0 -1
- package/lib/cjs/overrides/constants.js.map +0 -1
- package/lib/cjs/overrides/decoration.js.map +0 -1
- package/lib/cjs/overrides/helpers.js.map +0 -1
- package/lib/cjs/overrides/index.js.map +0 -1
- package/lib/cjs/overrides/overrides.js.map +0 -1
- package/lib/cjs/ram/RamRequestTransformer.js.map +0 -1
- package/lib/cjs/ram/index.js.map +0 -1
- package/lib/cjs/request/DecafAuthHandler.js.map +0 -1
- package/lib/cjs/request/DecafHandlerExecutor.js.map +0 -1
- package/lib/cjs/request/DecafRequestContext.js.map +0 -1
- package/lib/cjs/request/DecafResponseInterceptor.js.map +0 -1
- package/lib/cjs/request/index.js.map +0 -1
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { INestApplication, Logger, NestInterceptor, PipeTransform } from "@nestjs/common";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Defines all customizable parameters for Swagger setup.
|
|
5
|
+
*
|
|
6
|
+
* @summary
|
|
7
|
+
* This interface allows developers to customize how Swagger UI is configured
|
|
8
|
+
* within the NestJS application. It includes parameters for titles, paths,
|
|
9
|
+
* color schemes, and asset paths to tailor the API documentation experience.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} title - Title displayed in Swagger UI.
|
|
12
|
+
* @param {string} description - Description shown below the title.
|
|
13
|
+
* @param {string} version - API version displayed in the documentation.
|
|
14
|
+
* @param {string} [path] - Optional path where Swagger will be available.
|
|
15
|
+
* @param {boolean} [persistAuthorization] - Whether authorization tokens persist across reloads.
|
|
16
|
+
* @param {string} [assetsPath] - Path to custom assets for Swagger UI.
|
|
17
|
+
* @param {string} [topbarBgColor] - Custom background color for the Swagger top bar.
|
|
18
|
+
* @param {string} [topbarIconPath] - Path to a custom icon displayed in the top bar.
|
|
19
|
+
* @param {string} [faviconPath] - Path to a custom favicon.
|
|
20
|
+
*/
|
|
21
|
+
export interface SwaggerSetupOptions {
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
version: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
persistAuthorization?: boolean;
|
|
27
|
+
assetsPath?: string;
|
|
28
|
+
topbarBgColor?: string;
|
|
29
|
+
topbarIconPath?: string;
|
|
30
|
+
faviconPath?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Path to expose the OpenAPI specification in JSON format.
|
|
33
|
+
* Example: /api/openapi.json
|
|
34
|
+
*/
|
|
35
|
+
openApiJsonPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Path to expose the OpenAPI specification in YAML format.
|
|
38
|
+
* Requires 'yaml' package as peer dependency.
|
|
39
|
+
* Example: /api/openapi.yaml
|
|
40
|
+
*/
|
|
41
|
+
openApiYamlPath?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @description
|
|
45
|
+
* A fluent, static bootstrap class for initializing and configuring a NestJS application.
|
|
46
|
+
*
|
|
47
|
+
* @summary
|
|
48
|
+
* The `NestBootstraper` class provides a chainable API for configuring
|
|
49
|
+
* a NestJS application instance. It includes built-in methods for enabling
|
|
50
|
+
* CORS, Helmet security, Swagger documentation, global pipes, filters,
|
|
51
|
+
* interceptors, and starting the server.
|
|
52
|
+
*
|
|
53
|
+
* This class promotes consistency and reduces repetitive setup code
|
|
54
|
+
* across multiple NestJS projects.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { NestFactory } from "@nestjs/core";
|
|
59
|
+
* import { AppModule } from "./app.module.js";
|
|
60
|
+
* import { MyLogger } from "./MyLogger.js";
|
|
61
|
+
* import { NestBootstraper } from "@decaf-ts/for-nest";
|
|
62
|
+
*
|
|
63
|
+
* async function bootstrap() {
|
|
64
|
+
* const app = await NestFactory.create(AppModule);
|
|
65
|
+
*
|
|
66
|
+
* await NestBootstraper
|
|
67
|
+
* .initialize(app)
|
|
68
|
+
* .enableLogger(new MyLogger())
|
|
69
|
+
* .enableCors(["http://localhost:4200"])
|
|
70
|
+
* .useHelmet()
|
|
71
|
+
* .setupSwagger({
|
|
72
|
+
* title: "OpenAPI by TradeMark™",
|
|
73
|
+
* description: "TradeMark™ API documentation",
|
|
74
|
+
* version: "1.0.0",
|
|
75
|
+
* path: "api",
|
|
76
|
+
* persistAuthorization: true,
|
|
77
|
+
* topbarBgColor: "#2C3E50",
|
|
78
|
+
* topbarIconPath: "/assets/logo.svg",
|
|
79
|
+
* faviconPath: "/assets/favicon.ico"
|
|
80
|
+
* })
|
|
81
|
+
* .useGlobalFilters()
|
|
82
|
+
* .useGlobalPipes(...)
|
|
83
|
+
* .useGlobalInterceptors(...)
|
|
84
|
+
* .start(3000);
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* bootstrap();
|
|
88
|
+
* ```
|
|
89
|
+
* @class
|
|
90
|
+
*/
|
|
91
|
+
export declare class NestBootstraper {
|
|
92
|
+
private static app;
|
|
93
|
+
private static _logger;
|
|
94
|
+
/**
|
|
95
|
+
* @description
|
|
96
|
+
* Returns the current logger instance, creating a default one if not set.
|
|
97
|
+
*
|
|
98
|
+
* @summary
|
|
99
|
+
* Ensures that a valid `Logger` instance is always available
|
|
100
|
+
* for logging bootstrap-related messages.
|
|
101
|
+
*
|
|
102
|
+
* @return {Logger} The active logger instance.
|
|
103
|
+
*/
|
|
104
|
+
private static get logger();
|
|
105
|
+
/**
|
|
106
|
+
* @description
|
|
107
|
+
* Initializes the bootstrapper with a given NestJS application.
|
|
108
|
+
*
|
|
109
|
+
* @summary
|
|
110
|
+
* Binds the provided NestJS app instance to the bootstrapper, enabling
|
|
111
|
+
* chained configuration methods.
|
|
112
|
+
*
|
|
113
|
+
* @param {INestApplication} app - The NestJS application instance to initialize.
|
|
114
|
+
* @return {NestBootstraper} Returns the class for chaining configuration methods.
|
|
115
|
+
*/
|
|
116
|
+
static initialize(app: INestApplication): typeof NestBootstraper;
|
|
117
|
+
/**
|
|
118
|
+
* @description
|
|
119
|
+
* Enables or replaces the global logger for the NestJS application.
|
|
120
|
+
*
|
|
121
|
+
* @summary
|
|
122
|
+
* If a custom logger is provided, it replaces the default logger. Otherwise,
|
|
123
|
+
* a new logger named `"NestBootstrap"` is used. This logger is also registered
|
|
124
|
+
* with the NestJS application.
|
|
125
|
+
*
|
|
126
|
+
* @param {Logger} [customLogger] - Optional custom logger instance.
|
|
127
|
+
* @return {NestBootstraper} Returns the class for chaining.
|
|
128
|
+
*/
|
|
129
|
+
static enableLogger(customLogger?: Logger): typeof NestBootstraper;
|
|
130
|
+
/**
|
|
131
|
+
* @description
|
|
132
|
+
* Enables Cross-Origin Resource Sharing (CORS) for the application.
|
|
133
|
+
*
|
|
134
|
+
* @summary
|
|
135
|
+
* Allows defining either a wildcard origin (`"*"`) or a list of allowed origins.
|
|
136
|
+
* Automatically accepts local development requests and those without origin headers.
|
|
137
|
+
* Throws a `CorsError` for unauthorized origins.
|
|
138
|
+
*
|
|
139
|
+
* @param {'*' | string[]} [origins=[]] - List of allowed origins or `"*"` to allow all.
|
|
140
|
+
* @param {string[]} [allowMethods=['GET', 'POST', 'PUT', 'DELETE']] - Allowed HTTP methods.
|
|
141
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
static enableCors(origins?: "*" | string[], allowMethods?: string[]): typeof NestBootstraper;
|
|
145
|
+
/**
|
|
146
|
+
* @description
|
|
147
|
+
* Applies the Helmet middleware for enhanced security.
|
|
148
|
+
*
|
|
149
|
+
* @summary
|
|
150
|
+
* Dynamically loads the `helmet` package if available and registers it
|
|
151
|
+
* as middleware to improve HTTP header security. If not installed, logs a warning
|
|
152
|
+
* and continues execution without throwing errors.
|
|
153
|
+
*
|
|
154
|
+
* @param {Record<string, any>} [options] - Optional configuration passed to Helmet.
|
|
155
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
156
|
+
*/
|
|
157
|
+
static useHelmet(options?: Record<string, any>): typeof NestBootstraper;
|
|
158
|
+
/**
|
|
159
|
+
* @description
|
|
160
|
+
* Configures and initializes Swagger UI for API documentation.
|
|
161
|
+
*
|
|
162
|
+
* @summary
|
|
163
|
+
* Uses the `SwaggerBuilder` utility to configure API documentation
|
|
164
|
+
* with detailed customization for title, version, paths, and colors.
|
|
165
|
+
* Swagger is automatically exposed at the configured path.
|
|
166
|
+
*
|
|
167
|
+
* @param {SwaggerSetupOptions} options - Swagger configuration options.
|
|
168
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
169
|
+
*/
|
|
170
|
+
static setupSwagger(options: SwaggerSetupOptions): typeof NestBootstraper;
|
|
171
|
+
/**
|
|
172
|
+
* @description
|
|
173
|
+
* Registers one or more global validation pipes.
|
|
174
|
+
*
|
|
175
|
+
* @summary
|
|
176
|
+
* Enables request payload validation and transformation globally across
|
|
177
|
+
* the entire NestJS application. Multiple pipes can be chained together
|
|
178
|
+
* for modular input validation.
|
|
179
|
+
*
|
|
180
|
+
* @param {...PipeTransform[]} pipes - Pipe instances to register globally.
|
|
181
|
+
* @return {NestBootstraper} Returns the class for chaining.
|
|
182
|
+
*/
|
|
183
|
+
static useGlobalPipes(...pipes: PipeTransform[]): typeof NestBootstraper;
|
|
184
|
+
/**
|
|
185
|
+
* @description
|
|
186
|
+
* Registers one or more global exception filters.
|
|
187
|
+
*
|
|
188
|
+
* @summary
|
|
189
|
+
* If no filters are provided, it automatically registers a default
|
|
190
|
+
* set of standard exception filters for common error types like
|
|
191
|
+
* `HttpException`, `ValidationException`, `ConflictException`, and others.
|
|
192
|
+
*
|
|
193
|
+
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
194
|
+
*/
|
|
195
|
+
static useGlobalFilters(...filters: any[]): typeof NestBootstraper;
|
|
196
|
+
/**
|
|
197
|
+
* @description
|
|
198
|
+
* Registers global interceptors for request and response transformation.
|
|
199
|
+
*
|
|
200
|
+
* @summary
|
|
201
|
+
* Interceptors allow advanced request/response manipulation such as
|
|
202
|
+
* serialization, logging, or transformation. Multiple interceptors
|
|
203
|
+
* can be added for modular configuration.
|
|
204
|
+
*
|
|
205
|
+
* @param {...NestInterceptor[]} interceptors - Interceptor instances to register.
|
|
206
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
207
|
+
*/
|
|
208
|
+
static useGlobalInterceptors(...interceptors: NestInterceptor[]): typeof NestBootstraper;
|
|
209
|
+
/**
|
|
210
|
+
* @description
|
|
211
|
+
* Starts the NestJS application and binds it to the given port and host.
|
|
212
|
+
*
|
|
213
|
+
* @summary
|
|
214
|
+
* Listens on the specified port and optionally a host. Once started,
|
|
215
|
+
* logs the application URL for easy access. The startup process resolves
|
|
216
|
+
* once the application is successfully running.
|
|
217
|
+
*
|
|
218
|
+
* @param {number} [port=3000] - Port number to listen on.
|
|
219
|
+
* @param {string} [host] - Optional host or IP address to bind to.
|
|
220
|
+
* @param {boolean} [log=true] - Whether to log the application URL upon startup.
|
|
221
|
+
* @return {Promise<void>} Resolves once the application starts successfully.
|
|
222
|
+
*/
|
|
223
|
+
static start(port?: number, host?: string | undefined, log?: boolean): Promise<void>;
|
|
224
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cors.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cors.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OperationKeys } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
/**
|
|
5
|
+
* Builds a Nest/Swagger DTO class for the given model and CRUD operation.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - Only CREATE and UPDATE (and their bulk variants) produce a DTO;
|
|
9
|
+
* all other operations return the original model class unchanged.
|
|
10
|
+
* - @generated() properties (createdAt, updatedAt, createdBy, updatedBy,
|
|
11
|
+
* uuid, version, @composed pks, …) are **never** exposed in any DTO.
|
|
12
|
+
* - The @pk() property:
|
|
13
|
+
* • UPDATE – always included.
|
|
14
|
+
* • CREATE – included only when the pk is NOT auto-generated
|
|
15
|
+
* (checked via Model.pkProps().generated AND Model.generated()).
|
|
16
|
+
* - Relation properties (@oneToOne, @oneToMany, …):
|
|
17
|
+
* • CREATE – nested as DtoFor(CREATE, RelatedModel).
|
|
18
|
+
* • UPDATE – union of DtoFor(UPDATE, RelatedModel) **or** the
|
|
19
|
+
* related model's primary-key type (string / integer),
|
|
20
|
+
* expressed as a Swagger oneOf.
|
|
21
|
+
*
|
|
22
|
+
* Metadata.properties() now returns ALL properties across the prototype chain,
|
|
23
|
+
* so DTO inheritance is no longer needed; every DTO is a flat class.
|
|
24
|
+
*/
|
|
25
|
+
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M>): Constructor<any>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OperationKeys } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
/**
|
|
5
|
+
* Builds a Nest/Swagger DTO class for the given model and CRUD operation.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - Only CREATE and UPDATE (and their bulk variants) produce a DTO;
|
|
9
|
+
* all other operations return the original model class unchanged.
|
|
10
|
+
* - @generated() properties (createdAt, updatedAt, createdBy, updatedBy,
|
|
11
|
+
* uuid, version, @composed pks, …) are **never** exposed in any DTO.
|
|
12
|
+
* - The @pk() property:
|
|
13
|
+
* • UPDATE – always included.
|
|
14
|
+
* • CREATE – included only when the pk is NOT auto-generated
|
|
15
|
+
* (checked via Model.pkProps().generated AND Model.generated()).
|
|
16
|
+
* - Relation properties (@oneToOne, @oneToMany, …):
|
|
17
|
+
* • CREATE – nested as DtoFor(CREATE, RelatedModel).
|
|
18
|
+
* • UPDATE – union of DtoFor(UPDATE, RelatedModel) **or** the
|
|
19
|
+
* related model's primary-key type (string / integer),
|
|
20
|
+
* expressed as a Swagger oneOf.
|
|
21
|
+
*
|
|
22
|
+
* Metadata.properties() now returns ALL properties across the prototype chain,
|
|
23
|
+
* so DTO inheritance is no longer needed; every DTO is a flat class.
|
|
24
|
+
*/
|
|
25
|
+
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M>): Constructor<any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { INestApplication } from "@nestjs/common";
|
|
2
|
+
import { SwaggerOptions } from "./constants.cjs";
|
|
3
|
+
export declare class SwaggerBuilder {
|
|
4
|
+
private readonly app;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(app: INestApplication, options: SwaggerOptions);
|
|
7
|
+
private createDocument;
|
|
8
|
+
private registerOpenApiRoute;
|
|
9
|
+
setupSwagger(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { INestApplication } from "@nestjs/common";
|
|
2
|
+
import { SwaggerOptions } from "./constants.js";
|
|
3
|
+
export declare class SwaggerBuilder {
|
|
4
|
+
private readonly app;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(app: INestApplication, options: SwaggerOptions);
|
|
7
|
+
private createDocument;
|
|
8
|
+
private registerOpenApiRoute;
|
|
9
|
+
setupSwagger(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SwaggerUIOptions {
|
|
2
|
+
title?: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
persistAuthorization: boolean;
|
|
5
|
+
assetsPath?: string;
|
|
6
|
+
faviconPath?: string;
|
|
7
|
+
topbarIconPath?: string;
|
|
8
|
+
topbarBgColor?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class SwaggerCustomUI {
|
|
11
|
+
readonly options: SwaggerUIOptions;
|
|
12
|
+
constructor(options: SwaggerUIOptions);
|
|
13
|
+
private customCSS;
|
|
14
|
+
getCustomOptions(): {
|
|
15
|
+
customCss: string;
|
|
16
|
+
swaggerOptions: {
|
|
17
|
+
persistAuthorization: boolean;
|
|
18
|
+
};
|
|
19
|
+
customSiteTitle: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
b64(file: string, img?: boolean): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SwaggerUIOptions {
|
|
2
|
+
title?: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
persistAuthorization: boolean;
|
|
5
|
+
assetsPath?: string;
|
|
6
|
+
faviconPath?: string;
|
|
7
|
+
topbarIconPath?: string;
|
|
8
|
+
topbarBgColor?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class SwaggerCustomUI {
|
|
11
|
+
readonly options: SwaggerUIOptions;
|
|
12
|
+
constructor(options: SwaggerUIOptions);
|
|
13
|
+
private customCSS;
|
|
14
|
+
getCustomOptions(): {
|
|
15
|
+
customCss: string;
|
|
16
|
+
swaggerOptions: {
|
|
17
|
+
persistAuthorization: boolean;
|
|
18
|
+
};
|
|
19
|
+
customSiteTitle: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
b64(file: string, img?: boolean): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SecuritySchemeObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
export interface SwaggerOptions {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
assetsPath?: string;
|
|
8
|
+
faviconFilePath?: string;
|
|
9
|
+
topbarIconFilePath?: string;
|
|
10
|
+
persistAuthorization?: boolean;
|
|
11
|
+
path: string;
|
|
12
|
+
auth?: SecuritySchemeObject;
|
|
13
|
+
topbarBgColor?: string;
|
|
14
|
+
extraModels?: Constructor[];
|
|
15
|
+
/**
|
|
16
|
+
* Path to expose the OpenAPI specification in JSON format.
|
|
17
|
+
* Example: /api/openapi.json
|
|
18
|
+
*/
|
|
19
|
+
openApiJsonPath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Path to expose the OpenAPI specification in YAML format.
|
|
22
|
+
* Requires 'yaml' package as peer dependency.
|
|
23
|
+
* Example: /api/openapi.yaml
|
|
24
|
+
*/
|
|
25
|
+
openApiYamlPath?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const SWAGGER_UI_CONSTANTS: SwaggerOptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SecuritySchemeObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
export interface SwaggerOptions {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
assetsPath?: string;
|
|
8
|
+
faviconFilePath?: string;
|
|
9
|
+
topbarIconFilePath?: string;
|
|
10
|
+
persistAuthorization?: boolean;
|
|
11
|
+
path: string;
|
|
12
|
+
auth?: SecuritySchemeObject;
|
|
13
|
+
topbarBgColor?: string;
|
|
14
|
+
extraModels?: Constructor[];
|
|
15
|
+
/**
|
|
16
|
+
* Path to expose the OpenAPI specification in JSON format.
|
|
17
|
+
* Example: /api/openapi.json
|
|
18
|
+
*/
|
|
19
|
+
openApiJsonPath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Path to expose the OpenAPI specification in YAML format.
|
|
22
|
+
* Requires 'yaml' package as peer dependency.
|
|
23
|
+
* Example: /api/openapi.yaml
|
|
24
|
+
*/
|
|
25
|
+
openApiYamlPath?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const SWAGGER_UI_CONSTANTS: SwaggerOptions;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module for-nest
|
|
3
|
+
* @description This module serves as the main entry point for the ts-workspace library. It aggregates and exports
|
|
4
|
+
* functionality from various submodules and utilities within the project.
|
|
5
|
+
*
|
|
6
|
+
* The module includes:
|
|
7
|
+
* 1. Utility functions and types from the "./utils" directory:
|
|
8
|
+
* - These likely contain helper functions, common types, and shared functionality used throughout the project.
|
|
9
|
+
* - May include operations for data manipulation, type checking, or other general-purpose utilities.
|
|
10
|
+
*
|
|
11
|
+
* 2. A namespace and related types from the "./namespace" directory:
|
|
12
|
+
* - This could contain domain-specific code or a collection of related functionality.
|
|
13
|
+
* - Might include interfaces, types, or classes that represent core concepts in the library.
|
|
14
|
+
*
|
|
15
|
+
* 3. A VERSION constant:
|
|
16
|
+
* - Represents the current version of the module.
|
|
17
|
+
* - Useful for version checking and compatibility purposes.
|
|
18
|
+
*
|
|
19
|
+
* This structure provides a clean and organized export of the module's functionality, allowing consumers
|
|
20
|
+
* to easily import and use specific parts of the library as needed.
|
|
21
|
+
*/
|
|
22
|
+
import "./decoration";
|
|
23
|
+
export * from "./decoration.cjs";
|
|
24
|
+
export * from "./decaf-model/index.cjs";
|
|
25
|
+
export * from "./factory/index.cjs";
|
|
26
|
+
export * from "./interceptors/index.cjs";
|
|
27
|
+
export * from "./overrides/index.cjs";
|
|
28
|
+
export * from "./request/index.cjs";
|
|
29
|
+
export * from "./constants.cjs";
|
|
30
|
+
export * from "./controllers.cjs";
|
|
31
|
+
export * from "./module.cjs";
|
|
32
|
+
export * from "./core-module.cjs";
|
|
33
|
+
export * from "./types.cjs";
|
|
34
|
+
export * from "./utils.cjs";
|
|
35
|
+
export * from "./events-module/index.cjs";
|
|
36
|
+
/**
|
|
37
|
+
* Represents the current version of the ts-workspace module.
|
|
38
|
+
* The actual version number is replaced during the build process.
|
|
39
|
+
* @constant
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
42
|
+
export declare const VERSION = "0.6.0";
|
|
43
|
+
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module for-nest
|
|
3
|
+
* @description This module serves as the main entry point for the ts-workspace library. It aggregates and exports
|
|
4
|
+
* functionality from various submodules and utilities within the project.
|
|
5
|
+
*
|
|
6
|
+
* The module includes:
|
|
7
|
+
* 1. Utility functions and types from the "./utils" directory:
|
|
8
|
+
* - These likely contain helper functions, common types, and shared functionality used throughout the project.
|
|
9
|
+
* - May include operations for data manipulation, type checking, or other general-purpose utilities.
|
|
10
|
+
*
|
|
11
|
+
* 2. A namespace and related types from the "./namespace" directory:
|
|
12
|
+
* - This could contain domain-specific code or a collection of related functionality.
|
|
13
|
+
* - Might include interfaces, types, or classes that represent core concepts in the library.
|
|
14
|
+
*
|
|
15
|
+
* 3. A VERSION constant:
|
|
16
|
+
* - Represents the current version of the module.
|
|
17
|
+
* - Useful for version checking and compatibility purposes.
|
|
18
|
+
*
|
|
19
|
+
* This structure provides a clean and organized export of the module's functionality, allowing consumers
|
|
20
|
+
* to easily import and use specific parts of the library as needed.
|
|
21
|
+
*/
|
|
22
|
+
import "./decoration";
|
|
23
|
+
export * from "./decoration.js";
|
|
24
|
+
export * from "./decaf-model/index.js";
|
|
25
|
+
export * from "./factory/index.js";
|
|
26
|
+
export * from "./interceptors/index.js";
|
|
27
|
+
export * from "./overrides/index.js";
|
|
28
|
+
export * from "./request/index.js";
|
|
29
|
+
export * from "./constants.js";
|
|
30
|
+
export * from "./controllers.js";
|
|
31
|
+
export * from "./module.js";
|
|
32
|
+
export * from "./core-module.js";
|
|
33
|
+
export * from "./types.js";
|
|
34
|
+
export * from "./utils.js";
|
|
35
|
+
export * from "./events-module/index.js";
|
|
36
|
+
/**
|
|
37
|
+
* Represents the current version of the ts-workspace module.
|
|
38
|
+
* The actual version number is replaced during the build process.
|
|
39
|
+
* @constant
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
42
|
+
export declare const VERSION = "0.6.0";
|
|
43
|
+
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common";
|
|
2
|
+
import { Reflector } from "@nestjs/core";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import type { AuthHandler } from "../types.cjs";
|
|
5
|
+
export declare class AuthInterceptor implements NestInterceptor {
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
private readonly authHandler?;
|
|
8
|
+
constructor(reflector: Reflector, authHandler?: AuthHandler | undefined);
|
|
9
|
+
intercept(ctx: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common";
|
|
2
|
+
import { Reflector } from "@nestjs/core";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import type { AuthHandler } from "../types.js";
|
|
5
|
+
export declare class AuthInterceptor implements NestInterceptor {
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
private readonly authHandler?;
|
|
8
|
+
constructor(reflector: Reflector, authHandler?: AuthHandler | undefined);
|
|
9
|
+
intercept(ctx: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
|
|
2
|
+
import { DecafHandlerExecutor, DecafRequestContext } from "../request/index.cjs";
|
|
3
|
+
import { DecafServerCtx } from "../constants.cjs";
|
|
4
|
+
import "../overrides";
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* Interceptor responsible for executing all registered Decaf request handlers
|
|
8
|
+
* before the controller method is invoked.
|
|
9
|
+
*
|
|
10
|
+
* @summary
|
|
11
|
+
* The {@link DecafRequestHandlerInterceptor} integrates the Decaf request-handling pipeline
|
|
12
|
+
* into NestJS' interceptor mechanism. Before passing execution to the next handler in the
|
|
13
|
+
* NestJS chain, it delegates request processing to the {@link DecafHandlerExecutor}, which
|
|
14
|
+
* sequentially runs all registered {@link DecafRequestHandler} instances. This allows
|
|
15
|
+
* behaviors such as authentication, logging, tenant resolution, or metadata enrichment
|
|
16
|
+
* to occur prior to controller execution.
|
|
17
|
+
*
|
|
18
|
+
* @class DecafRequestHandlerInterceptor
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // Apply globally:
|
|
23
|
+
* app.useGlobalInterceptors(new DecafRequestHandlerInterceptor(executor));
|
|
24
|
+
*
|
|
25
|
+
* // Or in a module:
|
|
26
|
+
* @Module({
|
|
27
|
+
* providers: [
|
|
28
|
+
* DecafHandlerExecutor,
|
|
29
|
+
* {
|
|
30
|
+
* provide: APP_INTERCEPTOR,
|
|
31
|
+
* useClass: DecafRequestHandlerInterceptor,
|
|
32
|
+
* },
|
|
33
|
+
* ],
|
|
34
|
+
* })
|
|
35
|
+
* export class AppModule {}
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @mermaid
|
|
39
|
+
* sequenceDiagram
|
|
40
|
+
* participant Client
|
|
41
|
+
* participant Interceptor
|
|
42
|
+
* participant Executor
|
|
43
|
+
* participant Controller
|
|
44
|
+
*
|
|
45
|
+
* Client->>Interceptor: HTTP Request
|
|
46
|
+
* Interceptor->>Executor: exec(request)
|
|
47
|
+
* Executor-->>Interceptor: handlers completed
|
|
48
|
+
* Interceptor->>Controller: next.handle()
|
|
49
|
+
* Controller-->>Client: Response
|
|
50
|
+
*/
|
|
51
|
+
export declare class DecafRequestHandlerInterceptor implements NestInterceptor {
|
|
52
|
+
protected readonly requestContext: DecafRequestContext;
|
|
53
|
+
protected readonly executor: DecafHandlerExecutor;
|
|
54
|
+
constructor(requestContext: DecafRequestContext, executor: DecafHandlerExecutor);
|
|
55
|
+
protected contextualize(req: any): Promise<DecafServerCtx>;
|
|
56
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<any>>;
|
|
57
|
+
}
|