13 Node.js Frameworks to Build Web APIs Kristopher Sandoval October 26, 2017 Node.js is one of the most commonly used technologies in the web space. According to the StackOverflow 2017 survey, 47.1% of respondents who utilized frameworks and libraries utilized Node.js as a primary technology. This love is really no surprise – efficient, lightweight, and powerful, Node.js includes npm, the world’s largest open source library ecosystem, providing extensibility that has to be seen to be believed. With all of these options, we thought it would be a good idea to look at some of the best current frameworks, platforms, and libraries on offer for building web APIs. 1: Sails.js Realtime MVC Framework for Node.js Sails.js is a realtime MVC framework based on Express and Socket.io. This means that Sails is compatible with these types of projects, adding extensibility to many current projects. Sails.js is also very easy to deploy, and is relatively efficient for the codebase size that it has. While the Waterline ORM on the backend allows for storing data in virtually any datastore you’d want, the implementation itself can lead to bloated data storage. Many users report that multilevel population is extremely difficult, and this is echoed in their development path and feedback resources. Users often request Deep Population as a new feature, but it has yet to be approached. Should Sails.js implement Deep Population, it’d be a no brainer for Express projects. As it is now, it’s appropriate for most projects outside of enterprise and high-volume production environments. 2: Express.js Fast, unopinionated, minimalist web framework for Node.js Express is, in many ways, the progenitor of many solutions on this list. Initially lightweight in its base configuration, Express is designed to essentially function as middleware and as a routing framework. It does this very well, indeed, which is why it’s become part of the ever-popular MEAN stack for Node.js. The fact that Express doesn’t concern itself with code independence, however, is a major drawback. Once your code is written, it’s written, and changing it in a significant way can balloon the implementation and make for a terrible developer experience. Add on the lack of significant error handling and you’ve got a system that, while great for its time, and still effective in some use cases, is hard to outright recommend as a sole implementation. Express can best be summed up by its own branding – “unopinionated, minimalist framework”. On the one hand, that’s a good thing – on the other hand, this lack of defined, accepted solutions can add dramatic levels of complexity and result in projects that are difficult to maintain. That being said, Express still drives many of the implementations in the Node.js world, and in fact, is behind several of the high-profile implementations in this piece. For that reason, it should not be discounted as a legitimate option. 3: Hapi.js A rich framework for building applications and services Hapi.js is a one of the most enterprise-centric frameworks in this piece, and that makes sense – Hapi.js was created by, and is still maintained by, WalMart. It was initially created in preparation for the extreme online traffic of their Black Friday event. When WalMart was preparing for this traffic, they noticed the key issues with Express that we’ve already discussed – notably that, as the application grew in both size and demand, it became extremely unwieldy, and their Express-based solution made it extremely difficult to split into smaller chunks. Hapi.js was designed to fix this, and did so by implementing a plugin-based architecture. This allowed WalMart and other adopters of the framework to overhaul their systems, even replacing entire aspects of its functionality, without major issues. While it was originally based on Express, it has since moved away from it, and has become its own solution. While the plugin system was the perfect solution for WalMart’s problem, this complexity is often overkill for smaller organizations and solutions. It should also be noted that Hapi.js is still overseen by WalMart, who is responsible for the major additions to its codebase. While this is not in and of itself a bad thing, those who focus heavily on open source, non-corporate solutions might find this unappealing, and should consider that aspect before implementation. 4: actionHero.js Reusable, scalable, and quick node.js API server for stateless and stateful applications ActionHero.js is a highly featured framework that offers a variety of advanced functions. One of the biggest selling points is the fact that it supports delayed tasks. What this means in practice is that a task could be constructed to run at any time from a given device, making it portable across a wide variety of implementations. Additionally, actionHero is a light implementation, and as a result of its light build and relative simplicity, it’s also extremely fast. This, in addition to its very easy to understand and declarative routing, makes it prime for applications where function is needed to drive a complex system without itself adding complexity. There are negatives, however. actionHero is relatively new, so it’s not been run through the wringer that other implementations and frameworks have. It also caters relatively transparently to microservices, meaning that it’s not necessarily the best choice for enterprise solutions or for rapid development and prototyping of full API systems. 5: Total.js Total.js is full-featured server-side framework. Fast development, low maintenance cost, solid stability Total.js, like many on this list, markets itself as a “full-featured framework”, though with a server-side focus. Total.js supports MVC architecture, isomorphic code, image processing, RESTful routing, and more – it’s basically everything you’d want in a framework. A big selling point for Total.js is the fact that it’s compliant with and fully supports RFC 6455, and thereby WebSockets. This, alongside with its ability to merge .js and .css files, pushes Total.js in the direction that the Node.js industry has been drifting to for a while now, putting APIs that are implemented within Total.js at the forefront of cutting-edge implementations. Total.js should be a no-brainer for most applications, but the fact that it’s a full-stack platform means that incorporating it within an existing project is a hard sell. Moving from one platform to another is difficult, especially when you might already be dependent on another framework. 6: LoopBack LoopBack is a highly-extensible, open-source Node.js framework LoopBack is a full-featured backend framework that was designed from the ground up to connect applications to data using APIs. By packaging an API explorer, a variety of generators, SDKs in Angular, Browser, Node.js, iOS, Android, and Xamarin, and implementing a variety of code generators, LoopBack is appropriate for a wide range of both smaller projects and enterprise implementations. Additionally, LoopBack boasts an impressive amount of extensions, database integrations, and built-in models. This is paired with extensive and useful documentation. Unfortunately, you’re going to need that documentation. While LoopBack has simplified some aspects of its codebase, it still has a pretty steep learning curve due to the complexity of the solution and the numerous interactive parts. It should be noted here that, while LoopBack is still in current development, the developers have partnered with IBM to create IBM API Connect. Building upon the open-source successes of LoopBack, API Connect offers a range of tools that promises to make development easier. While there’s a great many features that are promised, but not yet integrated, the development of IBM API Connect and the future it promises makes LoopBack integration a much stronger argument. 7: Meteor A full-stack JavaScript platform for developing modern web and mobile applications Meteor is a full-stack, open-source framework and platform that aims to offer “a key set of technologies for building connected-client reactive applications, a build tool, and a curated set of packages from the Node.js and general JavaScript community”. Meteor is JavaScript-centric, and touts the benefit of using a singular language in JavaScript throughout all environments. Arguably, while this can be limiting, it can also negate cross-language issues that developers can run into in modern multi-device development. One of the main draws of Meteor is the fact that it uses so-called “data on the wire”. This means that Meteor doesn’t actually render data itself, instead choosing to transmit data for conversion and rendering on the client. This means that it’s extremely extensible and flexible. Additionally, Meteor uses hot code pushing, allowing all clients connected to the service to get automatic code pushes and updating. The one big fault that Meteor has is that there’s no current built-in solution for server-side rendering of views. While there is a third-party plugin for this, and there are plans to fully implement it, the lack of a built-in solution means that SEO can be negatively impacted on a default installation, requiring additional startup capital. 8: restify A Node.js web service framework optimized for building semantically correct RESTful web services Restify is a very popular solution for REST APIs in the current market. This is for good reason – restify boasts support for DTrace, has built in throttling, and is generally quite powerful. Restify is essentially Express lite, but with specific accepted implementations. This means there is less issue with project maintenance in the long run. Unfortunately, restify is beat out pretty handily by Express in terms of performance. Time and time again, restify APIs have shown decreased server function for large traffic flows and high demand, which results in an implementation that works great at first blush, but pales under heavy load. Considering the end goal of any API provider is a high traffic load, restify then must either be implemented as part of a solution that over-emphasizes load efficiency, or should be exchanged out for Express entirely. 9: Moleculer Fast & powerful microservices framework for NodeJS. Moleculer is an extensible library-based framework for Node.js that’s designed out of the box to be full-service-oriented. It does this by providing a variety of built-in modules, including caching and transport, that offers a wide range of functions in a highly extensible and modifiable way. One of the main selling points with Moleculer, a selling point that is in fact proudly featured on their documentation, is that Moleculer is fault tolerant, and includes a load balancer and circuit breaker. This is a great addition for a Node.js framework, and is especially necessary given the ever-increasing traffic demands of the modern web. With all that in mind, Moleculer is somewhat limited when compared to something like Express or Koa. It could be argued that Molecular is halfway between the overabundance of options and the limited options of divergent offerings – accordingly, a setup will depend on the limitations of smaller APIs or the higher demands of an enterprise API. 10: Koa.js A smaller, more expressive, and more robust foundation for web applications and APIs. Koa is a server-side web development framework built upon Node.js with the idea of leveraging generators. This concept allows the quick generation of web applications and REST APIs – at least in theory. The solution is quite modular, almost at the level of Hapi.js, and is extensible in a variety of unique ways. It should also be mentioned that Koa.js is the spiritual – and some would consider “official” – successor to Express.js. This is due to the fact that Koa was created by the original authors of Express, and specifically designed to be its replacement and fix for all the issues that Express has. Everything that Express does, Koa is meant to do in a more elegant way. That being said, Koa requires significant background knowledge of generators and promises, and thus requires a much larger capital for startup than other solutions. Koa is likely where the Express-based API space will migrate to, and for that reason, it’s a hard sell to adopt Express over Koa except in certain edge cases. 11: Frisby The Easiest And Fastest REST API Testing Framework Out There Frisby is a single-serve framework for testing. While single-serve frameworks, that is a framework that only does a single thing, is often considered a negative, Frisby handles testing in such a fast, effective manner that it warrants further review within many implementations. Unfortunately, speed is one of the only benefits that Frisby boasts. Documentation for Frisby is somewhat lacking, and what documentation is available is generally incomplete or otherwise lacking. The syntax of Frisby is also quite different from other implementations, which can very quickly make it feel alien to a new adoptee. Finally, and perhaps most importantly, Frisby doesn’t support the rolling back of transactions. The database will have to create a new record for each test, which in many cases is fine – when using in an IoT or lean case, however, where small databases and agile record-keeping is a requirement, Frisby becomes hard to argue for. That being said, if all you need is a fast testing platform and you have the database space so spare, as well as a developer familiar with the syntax, Frisby is a good option. 12: facet Rapid JSON API development. Facet brands itself less as a framework, and more as a “platform”. This makes sense, given that its stated purpose is to provide “extensible common utility classes for rapid JSON API development.” Because of this relatively specific focus, facet is heavily focused on including tools to make for easier development. First and foremost, facet is completely agnostic – this is accomplished by providing abstraction of middleware specific code and ensuring baked in CRUD functionality. By packaging everything and providing an interaction layer for the API, this means facet is a really good tool for long-term development across a variety of implementations and frameworks. Unfortunately, facet is still extremely small, and its development seems to have stagnated – the last GitHub commit was in 2014. The lack of comprehensive documentation on its official site and the absence of any significant amount of example code means that, were a provider to adopt facet, they would likely have an uphill battle to figure out the intricacies of the source code. A lack of community, a lack of certain features like logging, and the relative simplicity of the codebase makes it hard to argue for an established, demanding project. 13: Gugamarket Gugamarket is a fullstack REST API framework. Gugamarket is a full-stack REST API framework that is hard to summarize due to how its designed. Essentially, Gugamarket is what you make of it – a full-featured marketplace of implementations that one can build to their liking. Gugamarket has its shortcomings, and its strengths, depending on how it’s configured, and what it does. What could be said is that Gugamarket on the whole supports and offers integrations with Swagger, Express, and Mocha, and that its implementations on offer are rather well done. If the idea of an a la carte solution to API frameworks is appealing, it’s something developers should check out. Final Thoughts Node.js is extremely powerful. This power is only multiplied considering the huge range of options that providers have in terms of frameworks and platforms, opening providers up to an extreme range of functionalities, implementations, codebase sizes, and efficiencies. While it’s hard to recommend one over another given the fact that project designs and concepts are so wide-ranging, the glut of options on offer mean that for almost any project, there’s likely a strong solution. What do you think is the best overall Node.js framework? Let us know in the comments below, and be sure to check out our other pieces here on the Nordic APIs blog! Not using Node.JS? Read our articles on frameworks for Go, and PHP. The latest API insights straight to your inbox