Sails ships with several generators to help you scaffold new projects. You can also create your own generators to handle frequent tasks, or extend functionality (for example, by creating a generator that outputs view files for your favorite templating language).
The following generators are bundled with Sails:
sails generate new <appName>
Create a new Sails project in a folder called appName. See sails new
for usage options.
sails generate api <foo>
Generate api/models/Foo.js and api/controllers/FooController.js
sails generate model <foo> [attribute1:type1, attribute2:type2 ... ]
Generate api/models/Foo.js, optionally include attributes with the specified types.
sails generate controller <foo> [action1, action2, ...]
Generate api/controllers/FooController.js, optionally include actions with the specified names.
sails generate adapter <foo>
Generate a api/adapters/foo folder containing the files necessary for building a new adapter.
sails generate generator <foo>
Generate a foo folder containing the files necessary for building a new generator.
If you want to use Coffeescript for write your controllers or models even config files; just follow these steps:
package.json
file:npm install --save coffee-script
npm install --save-dev sails-generate-controller-coffee sails-generate-model-coffee
--coffee
:sails generate api <foo> --coffee
# Generate api/models/Foo.coffee and api/controllers/FooController.coffee
sails generate model <foo> --coffee
# Generate api/models/Foo.coffee
sails generate controller <foo> --coffee
# Generate api/controllers/FooController.coffee
Thats it, now you can write your code using Coffeescript!