framework-do-dede 1.0.16 → 1.0.18
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metrics, OffConsoleLog } from './controller';
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
4
|
import { Restrict, DbColumn } from './entity';
|
|
5
|
-
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch,
|
|
5
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn };
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Controller, Post, Get, Put, Delete, Patch, Validator, Middleware, Metrics, OffConsoleLog } from './controller';
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from './usecase';
|
|
3
3
|
import { Inject } from './di';
|
|
4
4
|
import { Restrict, DbColumn } from './entity';
|
|
5
|
-
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch,
|
|
5
|
+
export { Controller, Middleware, Validator, Metrics, OffConsoleLog, Post, Get, Put, Delete, Patch, Context, Inject, Restrict, DbColumn };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function Context(middlewareKey: string): (target: any, propertyKey: string) => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function Context(middlewareKey) {
|
|
2
2
|
return function (target, propertyKey) {
|
|
3
|
-
Reflect.
|
|
3
|
+
const metadata = Reflect.getMetadata('context', target.constructor) || [];
|
|
4
|
+
metadata.push({ propertyKey, middlewareKey });
|
|
5
|
+
Reflect.defineMetadata('context', metadata, target.constructor);
|
|
4
6
|
};
|
|
5
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dede, Register as DedeRegister, Options as DedeOptions } from './dede';
|
|
2
|
-
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware,
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, OffConsoleLog } from './decorators';
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
4
|
import { Validation, HttpMiddleware, UseCase, CreateRepository, ExistsById, DeleteRepository, UpdateRepository, RestoreRepository, RestoreManyRepository, RequestMetricsHandler, RequestData, RequestMetrics, HttpServerError } from './protocols';
|
|
5
5
|
import { Entity } from './domain/Entity';
|
|
6
6
|
declare class UseCaseHandler {
|
|
7
7
|
static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
|
|
8
8
|
}
|
|
9
|
-
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, HttpServerError, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, ExistsById, RestoreManyRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware,
|
|
9
|
+
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, HttpServerError, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, ExistsById, RestoreManyRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, Metrics, OffConsoleLog };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dede } from './dede';
|
|
2
|
-
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware,
|
|
2
|
+
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Restrict, Metrics, DbColumn, OffConsoleLog } from './decorators';
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
4
|
import { Registry } from './di/registry';
|
|
5
5
|
import { Entity } from './domain/Entity';
|
|
@@ -7,14 +7,13 @@ class UseCaseHandler {
|
|
|
7
7
|
static load(useCaseClass, request) {
|
|
8
8
|
const instance = Registry.classLoader(useCaseClass);
|
|
9
9
|
const context = request;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (middlewareKey && context?.middlewareData?.[middlewareKey]) {
|
|
10
|
+
const contextMetadata = Reflect.getMetadata('context', useCaseClass) || [];
|
|
11
|
+
contextMetadata.forEach(({ propertyKey, middlewareKey }) => {
|
|
12
|
+
if (context?.middlewareData?.[middlewareKey]) {
|
|
14
13
|
instance[propertyKey] = context.middlewareData[middlewareKey];
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
return instance;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
export { Dede, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware,
|
|
19
|
+
export { Dede, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Context, Inject, Entity, Restrict, DbColumn, Metrics, OffConsoleLog };
|