Closed SirMishaa closed 1 year ago
It looks like it's working when I wrap the result of the function into an object
container.bind<{ instance: FastifyInstance }>(TYPES.BaseHttpServer).toConstantValue(
{
instance: createHttpServer({
httpServerConfiguration: {
logger,
},
routes: routes(),
logger,
}),
},
)
// Usage
const httpServer = container.get<{ instance: FastifyInstance }>(TYPES.BaseHttpServer).instance
Someone can explain why? I'd like to understand
Oh, it looks like it's working also If I use await container.getAsync<FastifyInstance>(TYPES.BaseHttpServer)
, with this approach, I don't have to wrap to an object when binding.
I'm not sure to understand why because the function is not async
and do not return a Promise
.
Ok, that my bad, it looks like I have this error because the creation of an instance of Fastify returns a PromiseLike<T>
, I assume that Fastify is using duck typing and throw an exception if the value is Async / Promise.
Hello, I've started a project and I'm using Inversify, it's working good but when I try to bind / retrice my http server instance, I have errors :
Code is available here (there are just 3 files) : ==> https://gist.github.com/SirMishaa/c0da04d5c93b6c5cfd84836d39879ec1 <==
I'm a beginner with Fastify, so I may doing something wrong If it's really hard to debug, I can commit, push and send you I link to the repository (if it's really needed)
Thank you <3
Expected Behavior
Current Behavior
I got an error If I don't use .toString for Symbol (other usage of
container.get
works without it) :Error:
Fixed by using
TYPES.x.toString()
but why ? I don't have to do that for other usage of containerAnd the most important one, I got the following error :
Possible Solution
Steps to Reproduce (for bugs)
1. 2. 3. 4.
Context
Your Environment
Stack trace