Dev Environment
Install SailsJS
npm install sailsjs
Install Chrome Postman
Content-Type application/json
Quickly get started
Create a new sails app.
sails name_of_app
Create new sails using JADE
sails new name_of_app --template=jade
Fire up web server
sails lift
Create a model User. You can use this in production.
sails generate model user
This is the equivalent of rails scaffold except it's using JSON API
CRUD
Create a new user
http://localhost:1337/user/create?fname=chris&lname=aiv
List all users
http://localhost:1337/user/
Find a user
http://localhost:1337/user/findAll
Update a user
http://localhost:1337/user/update/1?email=signup@chrisaiv.com
Limit the results to 2
http://localhost:1337/user?limit=2
{
"where": {
},
"limit": 2,
"sort": "fname ASC"
}
Skipping for pagination
{
"where": {
},
"limit": 2,
"skip": 1
}
Search for people who have an "a" in their "fname"
{
"where": {
"fname": {
"contains": "a"
}
}
}
Who's name starts with a C
{
"where": {
"fname": {
"startsWith": "c"
}
}
}
Make requests using socket.io
io
io.connect("http://localhost:1337");
var socket = io.connect("http://localhost:1337");
socket.request('/user', {} ,function(users){console.log(users)});
Troubleshooting
Subscribe to new posts
Processing your application
Please check your inbox and click the link to confirm your subscription
There was an error sending the email