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.
– Integrating More
David Okun, Developer Evangelist, Strongloop & Swift@IBM
February 21, 2017
What is a Loopback?
• THE easiest & fastest
way to set up a
RESTful web API.
• Uses Express, Node,
• Get an API up with
writing zero code.
Extending Your API – The Scenario
• We have two immutable microservices.
• We want to combine their output and cache it
Aren’t Microservices Adorable?
• request-promise & bluebird
• Node.js & npm (I’m running 7.4.0 and 4.0.5)
• npm install –g loopback
• npm install –g strongloop
• The finished product can be found at:
Our Microservices – Up And Running
Setting up our Animal object
• A remote method is a method of a model.
• Can be made with lb remote-method.
• A remote hook is a function that can be
executed before or after a remote method is
• beforeRemote(), afterRemote(),
• An operation hook is a function triggered on a
higher-order function of a PersistedModel
Operation Hooks (cont.)
And we’re clear!!
• We aren’t validating the entries we get, so we
always get duplicates.
And we’re clear!!
Bonus Points: Validators
• Model objects can use a set of common
validators for convenience.
• Only supported with in-memory, Oracle, and
• 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.
• 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