Is there any tool or framework in Node.js that allows you to create a table in the DB and generate RESTful APIs automatically like Rails?
Thanks a lot!
Is there any tool or framework in Node.js that allows you to create a table in the DB and generate RESTful APIs automatically like Rails?
Thanks a lot!
I guess it depends on what you want:
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:
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.