Working with StrongLoop (Part One)

This post is more than 2 years old.

A few weeks back when I was shuttling back and forth between this side of the planet and the other, IBM purchased StrongLoop. I'll be honest and say that before this purchase, I had never heard of them. A quick perusal of their home page will tell you this:

Built on top of the open source LoopBack framework, StrongLoop allows you to visually develop REST APIs in Node and get them connected to your data. StrongLoop also features built-in mBaaS features like push and offline sync, plus graphical tools for clustering, profiling and monitoring Node apps.

This seemed interesting to me. Right now I'm at an interesting point in my Node.js development. I can write code. Not great code, and I need to copy and paste quite a bit, but I can build an application. On the hosting side, I've got multiple different ways of moving my application to production, including, of course, Bluemix.

What I haven't really gotten yet is the ecosystem around tools to help me build Node.js apps quicker as well as debugging and performance tuning. I feel like I'm just now getting to the point where it makes sense for me to learn more about this area and the StrongLoop acquisition is the perfect opportunity for me to do so.

StrongLoop has a number of features related to Node.js development, but for today's post, I'm going to focus on just one - the API Composer. At the simplest level, this is "just" a code generator, and I've got a bad history with code generators in general. I tried like heck to get behind Yeoman, but it simply never clicked for me and how I develop web apps. StrongLoop's tooling though works really well (as I hope you'll see) and so far I'm incredibly impressed.

The API Composer (and technically, I'm going to be showing the CLI as well as the graphic interface) is focused around building APIs. This is especially appealing to me because the more I work on the client-side, the leaner my server becomes. This is why I've been moving away from ColdFusion. I simply don't need my server to do much beyond simply proxying of API calls to various data sources. The more intelligent my front-end becomes the less intelligent (and complex) my back-end becomes. Let's consider a simple demo of what I'm talking about.

As a quick aside, if you are following along and actually doing these steps, you will eventually need to register at StrongLoop. You can do so here. This is free, and will be required to test the graphical stuff. I'm also assuming you have Node.js installed because, well, why wouldn't you?

The first thing you'll want to do is install StrongLoop itself. This can be done via npm:

npm install -g strongloop

This gives you the CLI tools as well as everything required to run the graphical portion as well.

Now, we'll build a sample app. At the command line, run this:

slc loopback

LoopBack is an open source Node.js framework that StrongLoop created, and their tooling runs on top of it. Some of what you'll see below is available in LoopBack and some just within StrongLoop itself. Running the above command will begin the app creation process.


After naming your app and entering a directory, the CLI will layout the app and end with this:


Fire up the application and you'll get two endpoints:


The home page just reports some startup info, but the explorer is where things get cool.


What you are seeing is automatic documentation for a simple modal called user. This is baked into the sample code and obviously you can rip this out if you don't need it. Clicking User expands the full list of methods available on it.

Screen Shot 2015-10-12 at 09.26.17

And you can then expand one particular method for more detail:


Notice that not only do you get quite a bit of information, you also get the ability to test the API directly on the page too. This is all really slick and well done, but let's actually make a proper model for our new application. We'll use the CLI first.

You begin by typing slc loopback:model. You'll be asked for the name of the model. Be sure to use the singular version as a later question will be what the plural should be. After entering the name of the model, you'll be asked about the data-source. Out of the box, you can use an in-memory database for testing. This is slick, but remember that every time you stop the Node.js app, the data will be cleared. (Not your models, they are store as files, but instances I mean.) If you want to play with the models and keep your data around, you may want to use one tab to run the application and one to use the CLI. You'll be asked a few more questions that you can just accept as default. StrongLoop supports things like MySQL and Mongo, and can be extended to support other data providers like Cloudant. (You'll see this in the next post!)


You're next asked to enter properties. Obviously this will depend on what your data is exposing. In the screen shot below I added three properties - name, gender, and color. I set these as strings, but I could have used different data types.


(Note - the deprecation warnings there aren't important and can be ignored.)

When done, I simply hit enter. Before we even look at the code, let's look at the API explorer again. As you can see, cat has been added as a model, and the properties match what I set up.


Cool. I scrolled down to the Put command and decided to build a cat (surprisingly easy to do compared to building a real cat):

Screen Shot 2015-10-12 at 09.43.56

The final test though was the raw API itself. I hit the GET API at http://localhost:3000/api/cats and got a list of my cats:


The API also has a butt-ton (marketing term) of filtering, sorting, limiting options built in too. We haven't yet looked at the code, so let's check it out. The core file for the Node.js app is really simple. Obviously a lot is going on behind the scenes, but the initial file is simple and not overwhelming.

var loopback = require('loopback');
var boot = require('loopback-boot');

var app = module.exports = loopback();

app.start = function() {
  // start the web server
  return app.listen(function() {
    var baseUrl = app.get('url').replace(/\/$/, '');
    console.log('Web server listening at: %s', baseUrl);
    if (app.get('loopback-component-explorer')) {
      var explorerPath = app.get('loopback-component-explorer').mountPath;
      console.log('Browse your REST API at %s%s', baseUrl, explorerPath);

// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
  if (err) throw err;

  // start the server if `$ node server.js`
  if (require.main === module)

This is all boiler plate, so let's look at how "cat" was added to the application. After I ran the CLI, two files were added to my common/models folder: cat.js and cat.json. cat.js is blank, well, mostly blank:

module.exports = function(Cat) {


The idea here is that you can add customized logic for your API calls. Perhaps the "free" version of your application only returns male cats. Whatever you want - you can easily add here. cat.json is the actual definition:

  "name": "cat",
  "plural": "cats",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  "properties": {
    "name": {
      "type": "string",
      "required": true
    "gender": {
      "type": "string",
      "required": true
    "color": {
      "type": "string",
      "required": true
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}

As you can see, this is all rather simple and easy to modify if you want to skip the CLI. You can also see optional items like validation support. I'm just barely scratching the surface here for the blog post.

At this point - I think we have something really freaking cool. Again, if you imagine a scenario where your server app is just a proxy between the client and databases, then what you've seen gets you a heck of a long way towards the finish line. Heck, you can build out a proof of concept server in minutes! Now let's take it a step further and look at the API Composer.

Technically what I'm going to show here is called Arc. Arc is a set of visual tools for your Node.js application. The API composer is just one small part of it. You begin by firing up the server:

slc arc

This opens up the web site in your default browser.


Now - I warned you above but it may be easy to forget. Even though this is your local server, you need to register at StrongLoop before you login here. I tried admin/admin which did not work. Once you login, just click the Composer link. The Composer gives you the ability to work with your model just like the CLI did. Here you can see the Cat model we just built.

Screen Shot 2015-10-12 at 09.59.54

I can then easily add a whole new model:

Screen Shot 2015-10-12 at 10.02.02

After saving the model, I can use the little Play icon the UI to restart the app so it picks up on the changes:


I built my - admittedly - simple dog model in about 60 seconds - restarted and then was able to hit http://localhost:3000/api/dogs and it freaking worked and that is awesome. I mean, I like visual building tools even less than I do generators and I'm 100% sold on this. (And to be clear, yes, I work for IBM, I'm supposed to like our stuff, but I hope my honest appreciation for this is coming through.)

As I said in the beginning, this is only one part of what StrongLoop offers. As I learn these tools I'm going to share my experience on the blog. If you have used StrongLoop, or LoopBack, I'd love to hear about your experiences below. Leave a comment and let me know what you think.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Jordan Kasper posted on 10/12/2015 at 3:52 PM

Really nice work here! Thanks for the write up. A couple notes:
* I'd probably use "POST" instead of "PUT" for REST API resource creation
* The sweet explorer interface is actually swagger-ui! LoopBack exports a swagger spec that the UI can consume, which is awesome because it means you can use that swagger spec elsewhere, and you can even build your API from an existing swagger spec!

Comment 2 (In reply to #1) by Raymond Camden posted on 10/12/2015 at 3:54 PM

Thanks for adding this, Jordan. Sometimes the relationship between so many different products can be confusing. :)

Comment 3 by Robert Zehnder posted on 10/12/2015 at 6:40 PM

Dang it Ray, I just signed up for an account. Another few weeks down the rabbit hole....

Comment 4 by Andrew Curry posted on 10/12/2015 at 10:29 PM

Excellent post! As a Rails developer getting into Node.js, I started using Strongloop recently and I've liked everything I've seen so far. I really like the JSON schema for model definitions - very easy to reason about validations & associations between models.

Comment 5 by Dan Skaggs posted on 10/13/2015 at 2:59 AM

Very timely post. I created a NodeJS API using HapiJS for the NCDevCon session Sharon DiOrio and I did because I'd heard good things about it (and because I was looking for a totally free solution). Just today I was reading some about StrongLoop and thinking maybe this is something to check out at my "day job" as we're starting to research what the replacement tech stack for CFML is going to look like.

Comment 6 by Justin James posted on 10/25/2015 at 7:58 PM

Had to add --msvs_version=2015 to the npm install -g strongloop command to get it working since I had multiple version of the C++ redistributable install.

Comment 7 (In reply to #6) by Raymond Camden posted on 10/26/2015 at 2:12 AM

Boggle - I love npm but when it goes weird, it really goes weird.

Comment 8 by Eduardo posted on 10/20/2016 at 3:31 PM

Hi Raymond, how are you, and need do a question !!!

I m doing a remoteMethod, ahd It must received a json.

MyUser.remoteMethod (
http: {path:'/loginAuth0', verb:'post'},
accepts:{arg:'user', type:'object'},
returns:{arg:'MyUser', type:'MyUser'}

MyUser.beforeRemote('loginAuth0', function( ctx, MyUser, next) {
console.log('calling '+ JSON.stringify(ctx.methodString));
console.log('calling '+;

When I call this method, I send the followed:


But from beforeRemote, I dont know, how can access to json data sending ??

Could you help me ?
eduardo https://uploads.disquscdn.c...

Comment 9 (In reply to #8) by Raymond Camden posted on 10/25/2016 at 3:00 PM

Are you asking how to access the data? It should be in ctx. I forget where, just console.log it to terminal and check it out.

Comment 10 (In reply to #9) by Eduardo posted on 10/25/2016 at 3:06 PM

I have resolved this, Thanks for your aswser

Comment 11 (In reply to #10) by Abhijeet Sharma posted on 11/28/2016 at 9:46 AM

I have created UI for login and singup can you tell me how get singup and login using this UI in Strongloop.

Comment 12 (In reply to #11) by Raymond Camden posted on 11/28/2016 at 2:33 PM

I have a complete demo of this that will be published on the StrongLoop Blog here, It isn't live yet, but will be this week I believe. You can find the code for it here:

Comment 13 by Anthony posted on 10/20/2017 at 7:02 AM


I am trying out loopback. It seems to be very easy to create CRUD APIs. However there doesn't seem to be a way to modify the APIs so that only the GET operations is exposed? Further more, how do I go about customizing the APIs to take different parameters?

Comment 14 (In reply to #13) by Anthony posted on 10/20/2017 at 7:17 AM

Ok, so I can add additional APIs through remote method.

But I still don't see in the loopback documentation on how to disable to the out of the box CRUD API.

Comment 15 (In reply to #14) by Raymond Camden posted on 10/20/2017 at 12:39 PM

Did you see the disableRemoteMethod API?

Comment 16 (In reply to #15) by Anthony posted on 10/20/2017 at 6:41 PM

This is exactly what I am looking for.

Thank you.