nehalist nehalist - 1 year ago 118
Node.js Question

Seperating client from server in Sails

I'd like to seperate the entire client from my sails directory. Currently it looks like

- api
- assets (my client)
- config
- views
- all the other sails stuff

What I want

- api
- config
- all the other sails stuff
- all client related stuff

Is there any easy and fast way to do this?


Answer Source

While it's best to stick to a conventional app structure, you can customize this by configuring sails.config.paths in your .sailsrc file. For example:

"paths": {
  "config": "server/api/config",
  "controllers": "server/api/controllers",
  // etc.

For assets/, you'll need to make some changes in tasks/pipeline.js, and in the Grunt task config files in tasks/config/*.

As to where you put views/, that's a really tough question that I went back and forth on many times over the year or so when I was initially working out the directory structure for the Sails boilerplate. That's the reason it lives up at the top level. I suppose if I had to categorize it within the scheme you're suggesting here, I would put it as "server/views/".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download