Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to define custom functions in loopback api

What is the best way to define custom functions in loopback api that can be used in models defined ?

For example a basic express application can have functions in helper folder on root directory, but doing same in loopback is not recommended and does not maintain loopback way.

Any help would be highly appreciated.

like image 616
Dharmendra Yadav Avatar asked Nov 26 '22 03:11

Dharmendra Yadav


1 Answers

This is very well documented.

Custom logic can be placed in

  • boot scripts
  • middlewares
  • models:
    • remote methods
    • remote hooks
    • operation hooks

application-decoupled logic can very well be put in helper folders, separate folders at root level, etc. There is nothing wrong with modularizing your program this way, it is actually a good thing.

like image 111
Overdrivr Avatar answered Dec 22 '22 12:12

Overdrivr