Q:

Sails app best practice

Hi I am creating a single page apps using Sails and Angular. I found the following example 
https://github.com/mikedevita/sailsjs-v10-angularjs-requirejs-boilerplate
https://github.com/levid/angular-sails-socketio-mongo-demo
https://github.com/chiefy/sails-angular-yeoman-logindemo
Was it the best way to do it? What if we totally separate our Angular app from our sails REST api. And run both of them using different port. When someone will knock our server we will use Ngnix to redirect them to our Angular app and Angular will knock our REST API Sails server. 
Which one would be a better practice? 

A:

I've not tested that project yet. That being said it looks pretty nice should everything work. Be warned that sails 0.10 is still in not a release (at the moment they're at rc3) so you shouldn't use it in production just now.
I've tried separating angular and sails to different servers before. It turned out to be a horrible mess, and quite painful. Issues include

having to whitelist sails domain for XHR requests
somehow generating CSRF tokens for form source validation
not being able to infuse the angular views with any server side templating (at least not with templates powered by sails)

Even if you were to set the sails and angular up by hand (as explained in the README.md of https://github.com/chiefy/sails-angular-yeoman-logindemo), it would be less of a struggle than using two out of the box solutions.
In practice you should use something like forever and cluster to increase performance and avoid down time (restart your server if it crashes).
Hope this helps. 
Edit:
Sails v0.10 has been released

A:

If you go with the option to use the same server for the two (socket and server), have you tried angular-sails-bind? (https://github.com/diegopamio/angular-sails-bind) I bet you haven't, as I've just released to the world a couple of minutes ago :). I made it for my own proyect and then decided to put it as a separated library so everybody could benefit and I could have my first experience developing a bower package.
I hope it could help you. So far, it uses the same base url, but I could easily make it configurable.
BTW: it works with sails 0.10 (as some things, like topic names had changed since 0.9). If you need to make it work with 0.9, just let me know and I'll happy to help.

