LoginSignup
3
3

More than 5 years have passed since last update.

Sailsでデフォルトの設定値を変更する

Last updated at Posted at 2014-04-29

Sailsバージョン:0.9.16

sails/lib/configuration/defaults.js内で定義されているデフォルトの設定値を変更する。
これを使うとモデルやコントローラーのパスその他もろもろのデフォルト設定値をsails.lift()の前に変更することが可能。

やり方は簡単で、sails.lift()の第一引数に変更したい設定値を渡すだけ。

app.js
// Start sails and pass it command line arguments
var path = require('path');
var config = require('optimist').argv;

// モデルディレクトリのパスをapi/modelsからapi/models2に変更
var modelPath = path.join(__dirname, 'api/models2');
config['paths'] = {models: modelPath};

require('sails').lift(config, function() {
    // 起動完了後に実行されるcallback
});
3
3
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
3
3