Recommend me a Node.js framework.

Darío Benítez on January 29, 2018

I'am a Django developer, and I really love this framework, specially the Django-ORM. But, I've been discarding several parts of Django for years.... [Read Full]
markdown guide
 

How's your experience with Python, Graphene and GraphQL? :-)

 

It's very good. Graphene is more easy to learn than Django Rest Framework. Certainly, if what I use works, maybe I should not change it.

But the world is moving towards JavaScript, and I want to carry out projects that may be up to date in several years.

 

Well, I wouldn't say the entire world is moving towards JS server side but it's true that there's more and more usage.

My interest in GraphQL stems from the fact that I feel the shortcomings of REST (especially around data querying and its design). Though maybe I can't yet use it for an external API, I think in the future I might be able to consider it for a "private" one.

That's why I asked about Python and GraphQL :-)

The design behind GraphQL really fixes many of the shortcomings of REST.

It's very useful in a frontend world where everything is based on the paradigm of components.

In the particular case of Django/Python, if your project doesn't require great scalability, I believe that Python performance processing GraphQL is excellent.

Thanks Darío. I'm communicating between frontend (Vue) and Server (Flask) using a semi-REST internal API and I'm already annoyed by the amount of data I send to components who don't need all of it :-D

 

I personally have 3 production Apps built in Sails.js and I found it to be really easy to work with. Important to note that Sails allows you to swap out the ORM to whatever you like so you aren't forced down the route of using Waterline. The same goes for the templating engine etc.

If you want a real world example of Sails.js and Vue.js working together you might want to take a look at these:

Sails and Vue Paypal Workflow: medium.com/@ahmedaminehachimi/payp...

Sails and Nuxt: github.com/AngelMunoz/sails-nuxt

Sails and Vue: github.com/ndabAP/vue-sails-exampl...

I know Mike (core contributor to Sails.js) is using it with Vue in production also so feel free to get hold of him on twitter or the gitter channel if you have issues.

I find sails super simple for building out API's it's just been one of those frameworks I "get", especially after I read Sails.js In Action which is perfect for understanding all the different features.

I've heard good things about Hapi framework also and KoaJS so might be worth looking into those also.

 

Hey there! glad to see the nuxt template is useful! I guess I'll have to update it soon!

 

Express is a super simple and robust framework for creating REST-style APIs in Node. I've been using it on a major project since late last year and have no complaints. I haven't used Sails, so I can't say much about that, except that I can't imagine anything being easier to use than Express.

I recommend against using Sequelize. It has a very large, inconsistent API and spotty documentation, and after trying it out for a few months I realized that an ORM in JavaScript isn't nearly as useful as an ORM in, say, .NET. If you've got any familiarity with SQL at all, I would recommend using a query builder like Knex.js instead. I switched my codebase entirely from Sequelize to Knex and it only took a week or two, and ended up vastly reducing the number of lines of code in my Node app and the number of SQL queries my program was executing. It also made everything more readable. I know an ORM seems like the easiest way to get up and running (especially if you're coming from a good one in another language), but I suggest taking some time to weigh the alternatives before you commit.

 

For when you want a little more than a query tool but less than a full-fledged O/RM, I maintain a data mapper for Node+Postgres. It works by introspecting your schema and building a database API with a fairly robust set of CRUD methods, plus some extra goodies like streamlined document management. If you need to run raw SQL, it treats script files exactly the same as database functions and has the obligatory db.query('something complicated') functionality.

 

100% agree - I recommend really reviewing whether you actually need an ORM at all. In a big enterprise application, maybe yes you save some time and increase consistency but when you are building anything small to medium size I really think its overkill. You can end up spending a lot of time building out your representations instead of just getting on with the actual task.

For me, ORM is a nice to have - I used it in Sails as it was nicely integrated at the time and my application was in-front of a database with 80 unique entities. However, an ORM can force you down a route of using some pretty crazy population methods or you end up breaking out into native code execution because the ORM can't handle the joins or representations you are trying to achieve. When you start to hit this point, for me I have to start questioning why I'm using an ORM in the first place and the benefits it is giving me.

I think my next project will start without and wait for the pay back to become more apparent before jumping into an ORM.

 

Stay with Django. I am mainly a JS developer and used Django in a previous job. The Django ORM is far better than any ORM/ODM in Node.js (Mongoose is good but is only for MongoDB). Use Django to create an API, either with Django Rest Framework or Graphene.

But I found Node.js really good for microservices where you may don't use a full ORM and instead write custom and optimized SQL/Mongo/whatever queries. If you want to go that way use Micro.

Or you can use graph.cool and Prisma which will generate a lot of things for you by only defining a GraphQL schema (magic similar to Django ORM) and you can use custom Node.js code for specific queries or mutations, in which case it's more similar to a microservice approach.

 

Hi Dario!

What is your objective to use Nodejs? I personally will use Express for a web application and Hapi for Rest API. You can check my advanced implementation of hapi here github.com/onkarjanwa/hapi-advance....

If you use Express for Rest API, you have to use middlewares while Hapi is straight forward and built for Implementing Rest API.

 

I want to create GraphQL APIs to use in SPA applications.

I've heard good comments about Express. I will try to write some prototype in Express to test more deeply.

 

As @imthedeveloper pointed out, Sails is a pretty good nodejs framework, it's my defacto one when building either personal projects or contracts, I've worked in two small companies in MX that use sails as their default solution.

Waterline is the weakness of sails in my opinion BUT just when you need to do complex stuff. For the most cases it will just work (and since it's node you can always require() anything specialized, like a query builder)

Strong points when it comes to sails:

  1. automatic rest endpoints for your actions(controllers)/models (can be configured)
  2. automatic orm for your model definitions
  3. automatic websockets functionalty (realtime baby)
  4. CORS enabled by default for production environments
  5. Sails CLI to scaffold and start your
  6. REPL of your sails app (one of the most underrated features)

for me sails just works, and if I need something I can always tune up/tune down settings, features of the framework or integrate my custom hooks (plugins), solutions (which I never had needed to use beyond learning purposes)

 

Agree on all of this and they have really improved so much over the last year.

You can run sails as a complete MVC project or you can run it headless and build without any views so you are API/ws only.

I personally use it for all of my sites which require a back end. I've had quite a few people starting to use it after they were shocked how quickly I was scaffolding a project during a Hackathon. The blueprint routes are just perfect for it.

 

What about Aurelia? I used it with GraphQL about 4 months ago. You can use it. It has an easy learning curve. For example, before I started to learn Aurelia I did not know anything about NodeJS frameworks (I was same as you).

Our project built with Aurelia. So, it currently working on production with 5k > visitors.

aurelia.io/

 

You should check out adonisjs. You can use it for a full stack app, or install a slimmer build for an api only.

Adonis uses knex under the hood and offers both a query builder and an orm.

The docs are quite good, and it's super simple to get started.

 

Hi Dario,

In production, when can I have a guide to connect sails.js on my google app engine to Google Cloud SQL via cloud sql proxy. Thanks

Regards
Mohd Izzuddin

 

There's also Loopback for REST APIs. It also generates a nice swagger UI. I haven't used it myself, but as others mentioned you may want to look into GraphQL.

 
code of conduct - report abuse