In Abstract
How to use Loopback 4
service generator and create local service class to handle data outside the *.repository
or *.controller
In Detail
I'm developing a system that requires external APIs to fetch data, complex hashing/encryption etc. that does not fall into controller scope or repository scope (for the sake of clean code). Loopback 4 has CLI command lb4 service
to generate service
and this is poorly documented. How to create a class inside the /service
folder and import (or inject or bind or whatever) and use it's methods as we do with repositories?
ex:
call methods from service like this.PasswordService.encrypt('some text')
or
this.TwitterApiService.getTweets()
that are defined in /service
directory