Managing LoopBack Configurations the Twelve-Factor Way

Share

Managing Loopback configuration files for multiple environments can be a hassle. In this blog we demonstrate how we do it using some well-known practices for scalable and maintainable codebases from the The Twelve-Factor App methodology. The key ideas are around storing configurations in environment variables rather than grouping configurations in a named group or polluting the codebase with configurations and constants.

Read more

Applying Custom Logic in Phases: Using Remote Hooks in LoopBack

Recently, we looked at how to use remote methods to expose custom logic as REST API endpoints in Loopback. That was pretty cool, but it just isn’t enough if we want to build a full-blown, production API. Even in a relatively simple case like exposing an inventory, if we threw a new endpoint at everything we’d very quickly end up with a poorly designed (not to mention ugly) API.

Luckily, Loopback provides a number of fine-grained ways to inject custom application logic into every level of our APIs. Let’s take a look at one of these options: remote hooks.

Read more

Working with LoopBack’s Object-Relational Mapping (ORM) System

When we talk about LoopBack, we’re usually talking about rapid API generation. But behind the REST APIs is a full object-relational mapping (ORM) system that enables you to do all the standard create, read, update, and delete (CRUD) operations in your Node.js code. If you’re creating only an API, then this may not be terribly important to you. But if you are creating both an API as well as a “regular” web site, then being able to use the ORM features could be very handy. While this is documented well in the “Working with data” section of the docs, I wanted to create a simple demo so I could wrap my head around how it actually feels to work with the server-side functions. I discovered that it is—for the most part—pretty simple, but model relationships add a few wrinkles that you have to consider when working with data.

Read more