-
Hi @Romakita, I need to access to export function MyDecorator(): ClassDecorator {
return useDecorators(
JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {
// I need to get REDIS_CONNECTION from here, connection already set in Configuration
}
)
}
// usage
@MyDecorator() // this read data from redis to perform some operation to the controller
class MyController {} Please guide me through how to achieve that. Many thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @datnq the normal flow is to set a metada related to a class and create a module or service to get the class & his metadata to implement something. also the connection is outside of the decorator scope. The DI container is also outside of this scope. So I won’t be able to help you and I won’t encourage you in this way. There is no reason to do that directly in a decorator! ( design pattern etc.) why do you need that? Maybe I can help you to find the corect way to do that! see you |
Beta Was this translation helpful? Give feedback.
Hello @datnq
You can take this PR as example:
https://github.com/tsedio/tsed/pull/2464/files
It uses custom decorator and consume metadata inside an injectable service ;)
See you