Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Customizing Loopback - Integrating More Modules

David Okun
February 21, 2017

Customizing Loopback - Integrating More Modules

Loopback is a great tool that allows you to generate an Express.js API from the command line. In this talk, I show you how you can take advantage of the Node.js ecosystem and integrate other modules into a Loopback API as business logic.

David Okun

February 21, 2017
Tweet

More Decks by David Okun

Other Decks in Programming

Transcript

  1. What is a Loopback? • THE easiest & fastest way

    to set up a RESTful web API. • Uses Express, Node, and Yeoman. • Get an API up with writing zero code.
  2. Extending Your API – The Scenario • We have two

    immutable microservices. • We want to combine their output and cache it locally.
  3. Setup • Node.js & npm (I’m running 7.4.0 and 4.0.5)

    • npm install –g loopback • npm install –g strongloop
  4. Today’s Demo • The finished product can be found at:

    • https://github.com/dokun1/LoopbackModulesDemo
  5. Remote Methods • A remote method is a method of

    a model. • Can be made with lb remote-method.
  6. Remote Hooks • A remote hook is a function that

    can be executed before or after a remote method is called. • beforeRemote(), afterRemote(), afterRemoteError().
  7. Operation Hooks • An operation hook is a function triggered

    on a higher-order function of a PersistedModel object.
  8. Bonus Points: Validators • Model objects can use a set

    of common validators for convenience. • Only supported with in-memory, Oracle, and MongoDB.
  9. Wrapping up • Loopback isn’t just for POCs – rather

    than limiting you to generated code, it supports what you want to build. • It gets out of the way when you need it to.
  10. Resources • https://loopback.io • Adding logic: https://loopback.io/doc/en/lb3/Adding-application-logic.html • Demo Repo:

    https://github.com/dokun1/LoopbackModulesDemo • Stack Overflow: http://stackoverflow.com/questions/tagged/loopback • Me on Twitter: @dokun24