Avoid @CreateRequestContext()
in NestJS
#5561
Unanswered
Borderliner
asked this question in
Q&A
Replies: 1 comment 4 replies
-
You are not supposed to do that, the decorator is there for a very specific use case (e.g. cron jobs), for HTTP request handles the nest adapter registers a middleware automatically.
You don't, you need to get the value from nest DI if you want this approach. You should not need this either, it happens automatically. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to avoid using
@CreateRequestContext()
on every route because I'm lazy. Is it possible to auto-fork with middleware in NestJS? I tried addingMikroOrmMiddleware
toapp.module.ts
to no avail like this:I don't know if it makes any difference, but notice that I'm initializing
MikroOrmModule
in anotherDatabaseModule
and notAppModule
itself.AppModule
has dependency onDatabaseModule
where it usesMikroOrmModule.forRoot()
.I wanted to use the below in my
main.ts
file, but didn't know how to initialize theorm
variable directly.Beta Was this translation helpful? Give feedback.
All reactions