Web Application Development with SailsJS
When I was doing my practical work for “Cloud application production” course I wondered many times isn’t there an easier way to do this? What is the point to waste time (and eventually money) e.g. for developing the REST API CRUD functionality. Yes, it is good to learn the basics, but really you should concentrate on customer problems not for the basic SW development.
I was already finished my practical work I started search for good framework for NodeJS, that would fulfill my requirements. A good NodeJS framework should generate REST API automatically, and it should not be dependent on any database type or UI framework. The only NodeJS framework that fulfilled my requirements is SailsJS.
- You can use any database with SailsJS, programming interface is same for all database types (Postgres, MySQL, MongoDB)
- REST API is generated automatically
- SailsJS is front-end framework agnostic
- Pretty good specs
- Community support
- SailsJS framework is versatile which makes it harder to learn
- What is performance for heavy loads?
- Is SailsJS ready for production? Current version is 0.12
How it works in practice?
I decided to try SailsJS by redoing the practical work for “Cloud application production” course. It took from me couple of days (I took months for me to do the practical work first time with NodeJS and ExpressJS). REST API was generated automatically, so it didn’t took any time and UI was already done. I needed to do few changes in Angular side, because REST API was different in SailsJS. I have to admit that generated REST API is much better that the one I did.
Creating a new app (from command shell or terminal)
sails new sails-test-app
Creating the REST API (in my case)
sails generate api group
sails generate api sensor
sails generate api measurement
Starting the server
In development phase all CRUD commands can be done with a web browser:
- Create: localhost:1337/group/create?groupName=awesome&description=testing
- Retrieve: localhost:1337/group
- Update: localhost:1337/group/update/<id>?description=testing too
- Delete: localhost:1337/group/delete/<id>
- More complicated queries can be done e.g. with Postman (more examples in the video)
Selected framework has very big impact on work performance. CRUD commands are created effortless and programmer can concentrate on solving the customer’s problems and not waste time on the basic stuff.
JWT authentication with SailsJS and AngularJS. In fact I already did it, but more about that in another post. Maybe next time.