Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Pronto.js: How ConsumerSearch's Mobile API Server is Driven by Node.js

Parent Feed: 

Pronto.js is designed to be a high performance asynchronous application framework that makes it simple to chain together components to build sophisticated application logic. It's the JS equivalent of the PHP Fortissimo framework.

One characteristic that makes both Pronto.js and Fortissimo stand apart is that they provide an alternative to the MVC pattern. They use the Chain-of-Command pattern, which takes a route name and maps it to a series of "commands", each of which is responsible for a different part of the processing. Well-written commands become highly reusable, which makes application development rapid and yet still reliable.

When you build an application the components get chained together into routes with code like this (Pronto.js):

register.route('search')
      .does(InitializeSearchService, 'initialization')
      .does(QueryRemoteSearchService, 'do-search')
        .uses('query').from('get:q')
      .does(SearchTheme, 'format-search-results')
        .uses('searchResults').from('cxt:do-search')
    ;

(Fortissimo code looks similar: $register->route('search')->does(/*…*/)) The simple example above registers the route search to a series of commands that each perform part of the overall task of running a search and formatting the response.

Commands (IntiailizeSearchService, QueryRemoteSearchService and so on) are short pieces of object-oriented code (prototypes in JS, classes in PHP) that take predefined input, perform a simple task, and then return data. My typical command is around 20 lines of code.

I know this is just a brief teaser. We're working on several cool applications built on these technologies. With Pronto.js, we've been able to integrate with a wide variety of NPM packages, while Fortissimo and the Symfony (and other) PHP libraries can be easily combined. In the future, I'll blog some more about Fortissimo and Pronto.js.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web