LoginSignup
9
9

More than 5 years have passed since last update.

【Sails.js 入門 - 02】Get Started

Last updated at Posted at 2013-05-30

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 ) 

http://localhost:1337/ を開く。

qiita-sails-beginner-02.png

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9