Today’s Demo
• The finished product can be found at:
• https://github.com/dokun1/LoopbackModulesDemo
Slide 10
Slide 10 text
Our Microservices – Up And Running
Slide 11
Slide 11 text
Loopback!
Slide 12
Slide 12 text
In-Memory Datasource
Slide 13
Slide 13 text
Setting up our Animal object
Slide 14
Slide 14 text
Model…
Slide 15
Slide 15 text
Model…
Slide 16
Slide 16 text
Model…
Slide 17
Slide 17 text
Model…
Slide 18
Slide 18 text
Sanity Check
Slide 19
Slide 19 text
Sanity Check
Slide 20
Slide 20 text
Remote Methods
• A remote method is a method of a model.
• Can be made with lb remote-method.
Slide 21
Slide 21 text
Animal.js
Slide 22
Slide 22 text
Remote Hooks
• A remote hook is a function that can be
executed before or after a remote method is
called.
• beforeRemote(), afterRemote(),
afterRemoteError().
Slide 23
Slide 23 text
Animal.js
Slide 24
Slide 24 text
Operation Hooks
• An operation hook is a function triggered on a
higher-order function of a PersistedModel
object.
Slide 25
Slide 25 text
Operation Hooks (cont.)
Slide 26
Slide 26 text
Animal.js
Slide 27
Slide 27 text
Animal.js
Slide 28
Slide 28 text
Animal.js
Slide 29
Slide 29 text
And we’re clear!!
Slide 30
Slide 30 text
But actually…
• We aren’t validating the entries we get, so we
always get duplicates.
Slide 31
Slide 31 text
Animal.js
Slide 32
Slide 32 text
Animal.js
Slide 33
Slide 33 text
Animal.js
Slide 34
Slide 34 text
Animal.js
Slide 35
Slide 35 text
And we’re clear!!
Slide 36
Slide 36 text
Bonus Points: Validators
• Model objects can use a set of common
validators for convenience.
• Only supported with in-memory, Oracle, and
MongoDB.
Slide 37
Slide 37 text
Animal.js
Slide 38
Slide 38 text
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.
Slide 39
Slide 39 text
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