Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inversify-express-utils] http request scope doesn't seem to be working as documented #1458

Open
xenoterracide opened this issue May 17, 2022 · 0 comments

Comments

@xenoterracide
Copy link

When I try to call the autofactory it says the service doesn't exist, if I don't use an autofactory it says the same thing but on parent service creation.

also interfaces.Autofactory doesn't exist. At the very least the documentation needs to improve to be correct. Ideally using something more complex than injecting a string.

Current Behavior

[back-end] [1652813224152] ERROR (CommentController/98837 on 5c52309d33e3): viewComments No matching bindings found for serviceIdentifier: ServiceNowUserByEidDataLoader

Steps to Reproduce (for bugs)

hopefully this is unambiguous and reproduceable

import e from 'express'
import { injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'

import { ServiceNowUserByEidDataLoader } from './service-now-user-by-eid-data-loader'

@injectable()
export class DataLoaderMiddleware extends BaseMiddleware {
  handler(req: e.Request, res: e.Response, next: e.NextFunction): void {
    this.bind(ServiceNowUserByEidDataLoader).toSelf().inSingletonScope()
    next()
  }
}

root container

container.bind(TYPES.UserInfoByEid).toAutoFactory(ServiceNowUserByEidDataLoader)
container.bind(DataLoaderMiddleware).toSelf()
  UserInfoByEid: Symbol.for('Factory<ServiceNowUserByEidDataLoader>'),

documentation suggests that you should use interfaces.Autofactory but we don't have that

@injectable()
export class UserService {
  private readonly log = LogProvider.getLogger()

  constructor(
    @inject(TYPES.UserInfoByEid)
    private readonly snUserDataLoader: () => ServiceNowUserByEidDataLoader
    )

... some method
    const dl = this.snUserDataLoader()

 @injectable()
export class ServiceNowUserByEidDataLoader extends AbstractDataLoader<ServiceNowUser> {

Your Environment

❯ uname -a && node --version && npm explain inversify inversify-express-utils
Darwin 5c52309d33e3 20.6.0 Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64 x86_64 i386 MacBookPro16,1 Darwin
v16.14.2
[email protected]
node_modules/inversify
  inversify@"^5.1.1" from [email protected]
  back-end
    [email protected]
    node_modules/back-end
      workspace back-end from the root project

[email protected]
node_modules/inversify-express-utils
  inversify-express-utils@"^6.3.2" from [email protected]
  back-end
    [email protected]
    node_modules/back-end
      workspace back-end from the root project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant