My opinionated view of Node.js frameworks
Node frameworks. So many of them. They all do different things. Each time I look into them I forget what they do. So I'm summarizing my impressions here. My search is usually around rapidly putting together an api / crud / database app that is easy to jump into.
Warning: I'm quite opinionated when it comes to what frameworks to adopt. Largely its because of years of going down a very promising path to find myself later googling obscure workarounds to get things to work. The below are my first impressions of frameworks based on a very quick review of how they work.
Overview
- A framework that allows defining 'services' which is basically a set of CRUD functions.
- The service can be customized using before and after hooks.
- It has built in REST / Sockets support via express or socketio.
- Database adapters that support in memory, local storage, filesystem, MongoDB (through mongoose), MySQL + others (through knex / sequelize) etc.
- It also provides client handlers that can be used by clients including browser to call services.
- Also provides a built in, extendable authentication service out of the box. (Supports Oauth as well)
- A lot of common hooks are already available in the feathers-hooks-common package
All in all this is a pretty awesome framework - I've started using this for my own projects.
Pros:
- Looks easy to use and customise
- Can switch databases easily (I hope)
- Documentation is pretty good
- Customising via hooks allows for concerns like validation, authorization etc to added in a modular way separating those concerns.
- Its just simple node modules. No global CLI required to bootstrap a folder full of files just to say hello world. (Although a CLI exists)
- Appears to be good adoption, support and community. List of feathers resources
- Supports a local file database as well as remote databases, so its good for rapidly putting together a simple app and migrating it later.
Cons:
- Still going to be hand-coding some logic but basic crud is built-in depending on the service
- Customising with hooks can be tricky until you get your head around it
- I really wish it would support extensibility of service functions (i.e. other than the CRUD)
- The database adapter documentation mentions you still may need to know mongoose / knex / sequelize so the ORM aspect of it may not be straightforward.
Loopback is basically a framework to build rest APIs. You define models that get used at the repository and api level as a DTO (data transfer object). You define the controller that handles the API logic.
Pros:
- Supports Swagger and the OpenAPI standard
- Convention over configuration
- Does away with a lot the plumbing work and seems conducive to rapid application development.
- Supports multiple repository types
- This is conceptually how I would implement something if I were to do it (except Loopback seems way more configurable - but complicated)
- Comes with an API explorer
Cons:
- It uses typescript. I dont like typescript.
- You can still write your custom code in just Javascript (ES6) but reading the examples is painful if you're not into TS.
- Seems a bit complicated to do more complicated things. Like i'd be spending time wrestling a bit with it later on.
- I tried the basic hello world example and the sheer number of files in the project folder is ridiculous.
- The documentation isnt the prettiest. (Yes I judge the elegance and ease of use of a product by how user friendly its website is.)
This is a lot like Express but for APIs, and less fiddling around with templating and responses etc. Essentially you define functions that handle each request based on a path.
Pros:
- Very low learning curve
- Its easy to customize
Cons:
- Still have to hand-code much of the handlers and data retrieval etc
- I dont see much advantage of this over Express really.
This looks like a more elegant version of Express. Looks good for web request code, and I plan to use this in the future in place of Express. However this doesnt seem to do much for rapid application development.
Others
Sails.js - I'll need to come back to this one when I have time.
Trails.js - didnt spend too much time on this; it has not had any commits since March 2018. The trailsjs.io website was not even up when I looked.