Replies: 1 comment
-
We would like to dynamically load the connector at runtime base on the client request, And we could not find a proper document or an example in loopback. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
we have the following scenario with REST custom connectors.
I have followed the lb4 guidelines to create REST based custom connectors, let's say i have two connectors i.e secrets and hello-world.
I also have the loopback application which has data sources, models, repositories and services for 2 integrations.
But i want to maintain a single controller which has service injection in constructor like below
@inject(ConnectorServiceBindings.CONNECTOR_SERVICE) public externalDataService: ConnectorRepositoryService,
here
ConnectorRepositoryService
is an interface which has contract for method calledgetSomething()
, so i have 2 services which implements interface for calling respective connector.So in my application.ts i have
this.bind(ConnectorServiceBindings.CONNECTOR_SERVICE).toClass( SecretsService, );
this to bind the injection with respective service.But i needed to have a condition here to select the binding like below
is there a way we can do this binding whenever we get new API request?????
FYI : controller has single POST end point which internally calls interface method using
this.externalDataService.getData?.()!;
Question 1 : Why do you want to bind at application.ts?
Ans : In future we want to add more connectors, so doesn't want to touch the controller code every time.
Beta Was this translation helpful? Give feedback.
All reactions