A former twenty something in technology

All posts tagged loopback

Separation of concerns using Loopback

Categories: nodejs
Comments: No
StrongLoop_logoA single code base application that contains your server side rendering, API (REST or otherwise), business logic, client side application and testing frameworks is nice when your application is small or you're showing a demo at a conference. However in the real world your application is likely much larger and intricate than that of a demo made in 5 minutes.


A little background. Loopback is a node based framework for building websites and applications created and maintained by Strongloop. The Strongloop team has provided examples as well as a command line application scaffolding utility to get you up and running quickly. While this scaffold-ed application is full featured and great for getting started. You are still left with an application that was created in 5 minutes. It will need a little thought and work to get it into a real world application.

 Separating out the pieces

The key to making this work is identifying what is required in each project in order to operate and function together. The primary points to focus on are:
  • Node modules
  • boot scripts
  • exporting module singleton objects (loopback & configuration)
  • middleware
  • model locations (specifically when utilizing loopback-component-passport)


Simply clone the API and SITE projects into their own directory. Then you can run node . in the api and site directories or create a combination script to start up both
var api = require('./api').loopback;
var site = require('./site');