REST CRUD Back-end Services in Seconds Without Writing One Line of Code
Create a Services Back-end in seconds with Node.js and Sails MVC Frameowrk
Scenario: You are a front-end developer that would like to test your newlydeveloped user interface, by pointing to some real back end services.
In today enterprise world, this can be a very time consuming and expensive challenge. Depending on your company structure, you might have to involve your management for approvals, procurement, and also the infrastructure, security, networking, back-end development, database teams, etc.
But all you need is some back-end service that can allow you to insert and retrieve some data, without wasting a month to get it accomplished.
This is how can you get it done without writing one line of code.
On your local machine or a development server (linux, mac os, windows):
1. Install node.js (http://nodejs.org/)
sudo yum install nodejs npm
2. Install sails (http://sailsjs.org/)
sudo npm -g install sails
3. Create new Sails Project
sails new TestBackend
4. Create your model
cd TestBackend
sails generate model NewsArticles
5. Start your services layer
cd TestBackend
sails lift
6. Test the server startup by accessing the default home page
http://localhost:1337/
7. Create a new news article
http://localhost:1337/NewsArticles/create?title=test&summary="I love sails"
8. Retrieve all news articles
http://localhost:1337/NewsArticles
9. Search by id, update by id, delete by id etc...
http://localhost:1337/NewsArticles/find/1
http://localhost:1337/NewsArticles/update/1?title=test2&summary="I love sails"
http://localhost:1337/NewsArticles/destroy/1
10. Now call the rest service from your front end code.
Comments
Post a Comment