Recently, I've been looking into StrongLoop's LoopBack framework. LoopBack generates Express REST APIs by asking you a few simple questions at the command line. LoopBack lets you swap out different storage layers. For each model you define, you can choose to store it in MongoDB, Oracle, MySQL, or Microsoft SQL Server (or even in memory). Say you decide to store your users in MongoDB but your user's gift cards in MySQL (for transactions). Even if you started writing your code with gift cards stored in MongoDB, LoopBack's database abstraction layer makes switching a one-liner. Furthermore, LoopBack has SDKs for generating REST API clients in AngularJS, Android, and iOS. In short, LoopBack is a powerful tool for generating REST APIs that you can extend to scaffold client-side code.

I'm usually not particularly keen on application scaffolding. Scaffolding frameworks generate code that your application may not need. This means your new project already starts off bloated. Furthermore, clearing away the scaffolding requires learning the framework's internals. But, LoopBack has several sweet features that help offset these difficulties.

Setting Up LoopBack

Before you dive into these features, you'll install LoopBack and create a new project. LoopBack comes with the strongloop npm module. StrongLoop recommends installing their npm module with the -g flag, but I avoid using -g where possible. You can install this module with -g, but it's not necessary. You'll want to go grab a cup of coffee, installing the strongloop module can take a few minutes.

mkdir loopback-example && cd loopback-example && npm install strongloop


REST APIs and Clients with LoopBack and AngularJS
3.70 GEEK