Loopback tip of the day: Nest Remoting

Brainfock uses Loopback framework at backend, which is an extension of ExpressJS and is really, really good for building REST APIs, allowing me to focus more on app business logic.

It is easy to create API endpoint to get info about any model, or get list of related models.

Consider the following: application has Workspace and Topic models. Each topic belongs to a workspace, and some topics may also be nested under parent topic.

Following documentation, in just a few minutes you can easily have these rest endpoints:

  • api/workspaces/123 — for info about workspace id 123
  • api/workspaces/123/topics — for list of topics inside of workspace 123
  • api/workspaces/123/topics/321 — to get topic id 321 that also belongs to workspace 123

Now, do you see where this is going?

I needed a way to also list topics of a topic of a workspace:


This did not work on it’s own (thank God!), but, as it turns out, there is an undocumented way to achieve this with Loopback: nest remoting.

So, how do you list models of a related model over REST API with Loopback?

I have to take a small step back and thank Loopback community (mainly residing at Gitter/Loopback) for being friendly, helpful and really professional!

So, to enable nest remoting, in my case, I had to call `nestRemoting` method from Workspace model and allow to access topics like this:


module.exports = function(Workspace) {
  Workspace.on('attached', function() {

Now, I have REST endpoint api/workspaces/123/topics/321/topics

Loopback tip of the day: Nest Remoting

Welcome Brainfock product blog

Hey there, thanks for coming!

I began building Brainfock for myself on local sandbox for personal use, and, as it happens with all passionate developers, I found myself spending more and more weekends on this project. It did not took long to realize it has to go open source, although getting to actual public release is a milestone yet to be conquered.

This blog will be covering important updates on Brainfock development process, releases and other happy news. I look forward to be sharing real experience and, of course, to grow team as we move on with the process.

So what is Brainfock? It’s a web-based tool to plan & manage projects, deals and all kinds of tasks in collaboration with team, or clients. As a developer I’m looking to build a product that will allow to manage any kind of tasks for individual users as well as small and medium businesses: from writing books to closing sales deals.

Current features:

  • Workspaces, Projects, Planning & Milestones, Tickets
  • Built-it discussion boards (per project, workspace etc)
  • Localization & i18n
  • Plugin system & modules system for backend and for web-client
  • Powerful user action events system
  • User Notification & Notification delivery systems
  • Customizable issue types
  • Intuitive interface
  • Backbone.js/Marionette-powered Web-client
Workspace projects (WIP)
Workspace projects (WIP)

I’m working hard to deliver first version of a product, which is planned to be publicly released early 2015 (release date TBA), and will require PHP 5.4+ & MySql 5+. Application backend is written in Yii Framework, which I’m successfully rockin’ since it’s first release; on frontend side we have a web client built with Backbone/Marionette.js as it’s base. I’m considering adding Node.js (optional?) support later down the road, but at this point it is not planned. I will definitely write another blog post about this.

Please, head to Github for available documentation — I will be releasing more stuff as I go on. One last thing to mention is at this stage Brainfock is a hobby project, and I’m dedicated to it.

For development & advanced deployment, project uses quite a few solutions: Composer for PHP dependency, NPM/Bowel for web-client libraries, Grunt for production deployment.

I will try to keep updates on this blog going, but please excuse me if you will not find new post for couple of days or weeks – the main goal is ready product and public release.

Project Issues Master-Detail view
Project Issues Master-Detail view

Follow Brainfock on Facebook, Twitter and fork me on Github to be the first one to get the source.

Sergii ‘Webkadabra’ Gamaiunov, project manager & author, webkadabra.com

Welcome Brainfock product blog