Finastra / finastra-nodejs-libs

A set of opinionated libraries for building efficient and scalable server-side applications with Node.js
MIT License
36 stars 14 forks source link

[OidcModule] Unable to run as per steps in readme #223

Open CosmoFruit opened 2 years ago

CosmoFruit commented 2 years ago
  1. run npm i @finastra/nestjs-oidc
  2. setup module as in readme

ERROR [ExceptionHandler] Nest can't resolve dependencies of the TokenGuard (Reflector, ?). Please make sure that the argument OidcService at index [1] is available in the AppModule context.

if we add import OidcModule in AppModule imports: [ OidcModule, OidcModule.forRootAsync({...})

then get next error: Nest can't resolve dependencies of the OidcService (?, SSRPagesService). Please make sure that the argument OidcModuleOptions at index [0] is available in the OidcModule context.

plz help to setup from scratch

Pi5rr5 commented 2 years ago

Hello, We have a starter repo that could help you to start from scratch! 🤞 https://github.com/Finastra/angular-nestjs-starter/blob/main/apps/server/src/app/app.module.ts

CosmoFruit commented 2 years ago

@Pi5rr5 thx for link, after some tests i have conclusion:

  1. all works fine when we use app.useGlobalGuards(app.get(TokenGuard));
  2. but if we want setup https://github.com/Finastra/finastra-nodejs-libs/tree/develop/libs/oidc#controller-or-route-based
    we catch error
    Nest can't resolve dependencies of the TokenGuard (Reflector, ?). Please make sure that the argument OidcService at index [1] i
    s available in the HealthModule context.

also reproduce in https://github.com/Finastra/angular-nestjs-starter/blob/main if off global use and add

@UseGuards(TokenGuard)
@Controller('health')

in https://github.com/Finastra/angular-nestjs-starter/blob/main/apps/server/src/app/health/health.controller.ts#L4