framework-do-dede 6.2.3 → 6.3.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/README.md +20 -0
- package/dist/application/controller.d.ts +1 -0
- package/dist/application/controller.js +10 -0
- package/dist/application/index.d.ts +2 -2
- package/dist/application/index.js +2 -2
- package/dist/http/controller.handler.js +5 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,6 +317,26 @@ const app = await Dede.create({
|
|
|
317
317
|
Com `framework.tracer: true`, todos os controllers/metodos passam a usar tracer por padrao.
|
|
318
318
|
`@Tracing(new MeuTracer())` ainda sobrescreve por controller/metodo.
|
|
319
319
|
|
|
320
|
+
Para ignorar tracing em um controller/rota especifica quando o tracing global estiver ligado, use `@NoTracing()`:
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
import { NoTracing } from './src';
|
|
324
|
+
|
|
325
|
+
@NoTracing()
|
|
326
|
+
@Controller('/health')
|
|
327
|
+
class HealthController {
|
|
328
|
+
@Get('/ping')
|
|
329
|
+
async ping() { return { ok: true }; }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
@Controller('/users')
|
|
333
|
+
class UserController {
|
|
334
|
+
@NoTracing()
|
|
335
|
+
@Get('/public')
|
|
336
|
+
async publicRoute() { return { ok: true }; }
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
320
340
|
### UseCase e Decorators
|
|
321
341
|
|
|
322
342
|
UseCase provê `data` e `context` do request.
|
|
@@ -35,6 +35,7 @@ export interface Input<T, K = any> {
|
|
|
35
35
|
type BodyFilter = "restrict" | "none";
|
|
36
36
|
export declare function Controller(basePath?: string): (target: any) => void;
|
|
37
37
|
export declare function Tracing<R>(tracer?: Tracer<R>): (target: any, propertyKey?: string) => void;
|
|
38
|
+
export declare function NoTracing(): (target: any, propertyKey?: string) => void;
|
|
38
39
|
export declare function Version(version: number): (target: any, propertyKey?: string) => void;
|
|
39
40
|
export declare function PresetIgnore(ignorePrefix?: boolean, ignoreVersion?: boolean): (target: any, propertyKey?: string) => void;
|
|
40
41
|
export declare function UseMiddleware(middlewareClass: MiddlewareDefinition): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
|
|
@@ -22,6 +22,16 @@ export function Tracing(tracer) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
export function NoTracing() {
|
|
26
|
+
return function (target, propertyKey) {
|
|
27
|
+
if (!propertyKey) {
|
|
28
|
+
Reflect.defineMetadata('noTracing', true, target);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
Reflect.defineMetadata('noTracing', true, target, propertyKey);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
25
35
|
export function Version(version) {
|
|
26
36
|
return function (target, propertyKey) {
|
|
27
37
|
if (!Number.isInteger(version) || version <= 0) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version, PresetIgnore, type Middleware, type Input, type Tracer, type TracerData } from './controller';
|
|
1
|
+
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, NoTracing, Version, PresetIgnore, type Middleware, type Input, type Tracer, type TracerData } from './controller';
|
|
2
2
|
import { Entity, Restrict, VirtualProperty, GetterPrefix, Transform } from '../infra/serialization/entity';
|
|
3
3
|
import { Model, column } from '../infra/model/model';
|
|
4
4
|
import { DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter } from './usecase';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, };
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, NoTracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, };
|
|
6
6
|
export { Storage, CacheGateway, EventDispatcher } from './services';
|
|
7
7
|
export type { Middleware, Input, Tracer, TracerData };
|
|
8
8
|
export type { StorageGateway } from './services';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, Version, PresetIgnore } from './controller';
|
|
1
|
+
import { Controller, Post, Get, Put, Delete, Patch, UseMiddleware, UseMiddlewares, Tracing, NoTracing, Version, PresetIgnore } from './controller';
|
|
2
2
|
import { Entity, Restrict, VirtualProperty, GetterPrefix, Transform } from '../infra/serialization/entity';
|
|
3
3
|
import { Model, column } from '../infra/model/model';
|
|
4
4
|
import { DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, } from './usecase';
|
|
5
|
-
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, };
|
|
5
|
+
export { Controller, UseMiddleware, UseMiddlewares, Post, Get, Put, Delete, Patch, Tracing, NoTracing, Version, PresetIgnore, DecorateUseCase, UseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, };
|
|
6
6
|
export { Storage, CacheGateway, EventDispatcher } from './services';
|
|
@@ -99,6 +99,7 @@ export default class ControllerHandler {
|
|
|
99
99
|
for (const controller of controllersList) {
|
|
100
100
|
const basePath = Reflect.getMetadata('basePath', controller);
|
|
101
101
|
const methodNames = Object.getOwnPropertyNames(controller.prototype).filter(method => method !== 'constructor');
|
|
102
|
+
const controllerNoTracing = Reflect.getMetadata('noTracing', controller) === true;
|
|
102
103
|
const controllerTracerMetadata = Reflect.getMetadata('tracer', controller)
|
|
103
104
|
|| (this.tracerEnabled ? { fromContainer: true, token: DEFAULT_TRACER_TOKEN } : null);
|
|
104
105
|
const controllerVersion = Reflect.getMetadata('version', controller);
|
|
@@ -111,7 +112,10 @@ export default class ControllerHandler {
|
|
|
111
112
|
const middlewares = [...controllerMiddlewares, ...methodMiddlewares];
|
|
112
113
|
const responseType = routeConfig.responseType || 'json';
|
|
113
114
|
const methodTracerMetadata = Reflect.getMetadata('tracer', controller.prototype, methodName);
|
|
114
|
-
const
|
|
115
|
+
const methodNoTracing = Reflect.getMetadata('noTracing', controller.prototype, methodName) === true;
|
|
116
|
+
const tracerMetadata = (methodNoTracing || controllerNoTracing)
|
|
117
|
+
? null
|
|
118
|
+
: methodTracerMetadata || controllerTracerMetadata;
|
|
115
119
|
const tracer = this.resolveTracer(tracerMetadata);
|
|
116
120
|
const methodVersion = Reflect.getMetadata('version', controller.prototype, methodName);
|
|
117
121
|
const methodPresetIgnore = Reflect.getMetadata('presetIgnore', controller.prototype, methodName);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher } from "./application";
|
|
1
|
+
import { Post, Get, Put, Delete, Patch, Controller, Input, Version, PresetIgnore, NoTracing, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher } from "./application";
|
|
2
2
|
import { Container, DefaultContainer, Inject, setDefaultContainer } from './infra/di/registry';
|
|
3
3
|
import { Dede, type Options, Register } from './dede';
|
|
4
4
|
import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError } from './http/errors/server';
|
|
@@ -8,5 +8,5 @@ import type { ValidatorDefinition } from './interface/validation/validator';
|
|
|
8
8
|
import type { StorageGateway, Event, EventPayload } from './application';
|
|
9
9
|
import { RepositoryModel } from './protocols/model';
|
|
10
10
|
import type { RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryExistsBy, RepositoryRestore, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination } from './protocols/repository';
|
|
11
|
-
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, PresetIgnore, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, Options, Register, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, Optional, RepositoryModel, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
|
11
|
+
export { Controller, Post, Get, Put, Delete, Patch, Input, Version, PresetIgnore, NoTracing, Middleware, UseMiddleware, UseMiddlewares, Tracer, Tracing, TracerData, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, Options, Register, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, Optional, RepositoryModel, RepositoryCreate, RepositoryUpdate, RepositoryRemove, RepositoryRemoveBy, RepositoryRestore, RepositoryExistsBy, RepositoryRestoreBy, RepositoryNotExistsBy, RepositoryPagination };
|
|
12
12
|
export type { ValidatorDefinition, StorageGateway, Event, EventPayload };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
// controller
|
|
3
|
-
Post, Get, Put, Delete, Patch, Controller, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing,
|
|
3
|
+
Post, Get, Put, Delete, Patch, Controller, Version, PresetIgnore, NoTracing, UseMiddleware, UseMiddlewares, Tracing,
|
|
4
4
|
// controller
|
|
5
5
|
// entity
|
|
6
6
|
Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column,
|
|
@@ -18,4 +18,4 @@ import { ServerError, NotFound, Forbidden, Conflict, Unauthorized, Unprocessable
|
|
|
18
18
|
import { AppError } from './domain/errors/app-error';
|
|
19
19
|
import { Optional } from './domain/optional';
|
|
20
20
|
import { RepositoryModel } from './protocols/model';
|
|
21
|
-
export { Controller, Post, Get, Put, Delete, Patch, Version, PresetIgnore, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, Optional, RepositoryModel };
|
|
21
|
+
export { Controller, Post, Get, Put, Delete, Patch, Version, PresetIgnore, NoTracing, UseMiddleware, UseMiddlewares, Tracing, Entity, Restrict, VirtualProperty, GetterPrefix, Transform, Model, column, UseCase, DecorateUseCase, Hook, BeforeHook, AfterHook, HookBefore, HookAfter, Storage, CacheGateway, EventDispatcher, Inject, Container, DefaultContainer, setDefaultContainer, Dede, ServerError, NotFound, Forbidden, Conflict, Unauthorized, UnprocessableEntity, BadRequest, InternalServerError, CustomServerError, AppError, Optional, RepositoryModel };
|