Get Started
ここはできるだけシンプルにするため、めっちゃ頑張っている。 ただ Sails.js をインストールして、新しいプロジェクトを作って、サーバに載せる。
・・・らしいです。ここからは、訳者勝手にアレンジ。
Installation
最新の sails をコマンドラインでインストール。各種のコマンドラインからのテンプレート生成のためにグローバル(-g)でインストール
sudo npm -g install sails
コマンドは何があるかな
$ sails
debug: Welcome to Sails! (v0.8.91)
info: Usage: sails <command>
sails lift Run this Sails app (in the current dir)
[--dev] with development environment specified
[--prod] with production environment specified
sails console Run this Sails app (in the current dir & in interactive mode.)
sails new <appName> Create a new Sails project in the current dir
sails generate <foo> Generate api/models/Foo.js and api/controllers/FooController.js
sails generate model <foo> Generate api/models/Foo.js
sails generate controller <foo> Generate api/controllers/FooController.js
sails version Get the current globally installed Sails version
Creating a New Sails Project
新しいプロジェクトを作成
$ sails new app02
debug: Generating app directory...
info: Generating Sails project (app02)...
debug: Generating package.json...
debug: Generating README.md...
中身を見てみる。
$ tree
.
└── app02
├── api
│ ├── adapters
│ ├── controllers
│ ├── models
│ ├── policies
│ │ └── authenticated.js
│ └── services
├── app.js
├── assets
│ ├── js
│ ├── mixins
│ │ ├── reset.css
│ │ └── sails.io.js
│ ├── styles
│ └── templates
├── config
│ ├── adapters.js
│ ├── application.js
│ ├── assets.js
│ ├── bootstrap.js
│ ├── locales
│ │ └── english.js
│ ├── local.ex.js
│ ├── local.js
│ ├── policies.js
│ ├── routes.js
│ └── views.js
├── package.json
├── public
│ ├── favicon.ico
│ ├── images
│ └── robots.txt
├── README.md
└── views
├── 404.ejs
├── 500.ejs
├── home
│ └── index.ejs
└── layout.ejs
起動してみる
作成したプロジェクトに cd して、lift コマンドを打つ
$ cd app2
$ sails lift
debug: Starting server in /path/to/sails/app02...
info - socket.io started
debug:
debug:
debug:
debug:
debug: <|
debug: |
debug: \\____//
debug: --___---___--___---___--___---___
debug: --___---___--___---___--___---___
debug:
debug: Sails (v0.8.91)
debug: Sails lifted on port 1337 in development mode.
debug:
debug: ( to see your app, visit: http://localhost:1337 )