Is there anything in Node.js like scaffold in Rails? [closed] Is there anything in Node.js like scaffold in Rails? [closed] ruby-on-rails ruby-on-rails

Is there anything in Node.js like scaffold in Rails? [closed]


I guess it depends on what you want:

  • Rails style code generation (where it generates code for you that you can modify)
  • Django style semi magic where admin forms can be derived from the fields in your table/document schema.
  • you mean generating an API for these fields in the database, ala what grape does for Ruby -- you do some configuration and translating data to JSON and transmitting it back over the wire is taken care of for you
  • You have a new project and you're looking for a framework with one of these three characteristics

For the first three options there are a few related SO questions on this already:

There are a few awesome answers in this set of links, including:

For the last option - an opinionated rapid web development Node.js framework that provides good API support, there are a few options:

  • @abject_error's answer, in this question, about Sails
  • Geddy <-- automatically provides .json versions of the data your controller specifies (depending on the request it uses this data to render HTML views or creates a JSON representation)
  • There's a nice slide-show on How to quickly make REST APIs with CompoundJS, so CompoundJs may fit your tastes.

I initially left these off as I assumed you may have an existing project, or didn't want to use an opinionated framework, but added them because why not.


SailsJS (https://github.com/balderdashy/sails) is exactly what you're looking for. It uses the Waterline module for simulating ActiveRecord. Just define a resource, and it will automatically create JSON endpoints for all RESTful actions, and also makes the endpoints compatible with Socket.io connections.

It's built on Express, so you can use any Connect middleware to extend it. AFAIK it's the best NodeJS framework for building API backends.

Defining a new resource is as simple as sails generate user. This will create the appropriate model and controller files, which you can then modify.

Keep in mind Sails was built with schema-less datastores in mind, so it's primary support is for MongoDB, not MySQL. I'm not sure how well (if at all) it supports SQL databases.