Commit Graph

7 Commits

Author SHA1 Message Date
Miroslav Bajtoš 1f1bc7aeab fixup! change debug logger name to 'loopback:boot' 2014-05-28 09:44:06 +02:00
Miroslav Bajtoš 255217f6a7 Ignore models/ and boot/ subdirs without index
Sub-directories of `models/` and `boot/` that cannot be required
(they don't have an index.js file) are silently skipped now.

This enables developers to put test files into `models/test/`.
2014-05-27 16:44:21 +02:00
Miroslav Bajtoš 3ba43e1197 Pass `app` to fn exported by auto-required script
When a script in `models/` or `boot/` exports a function which is not
a loopback.Model constructor, the bootstrapper immediatelly calls
this exported function wit the current `app` object.

This is providing a dependency injection mechanism for boot scripts,
so that they no longer need to know where to find the `app` object.

Note: the dependency injection is optional. Existing code getting
`app` reference via `require('../app')` will continue to work.
2014-05-27 16:11:54 +02:00
Miroslav Bajtoš 9930934686 cleanup: remove unused code in requireDir()
No changes in functionality.
2014-05-27 16:05:43 +02:00
Miroslav Bajtoš 2a619773d4 Custom rootDir for models and datasources
Support custom project layouts where model & datasource config files
are located in a different place from the app config.

Example:

    # API server
    server/app.config.json
    server/datasources.json

    # shared between server & client
    models.json
    models/

    # isomorphic client
    client/app.config.json
    client/datasources.json
2014-05-27 14:49:11 +02:00
Miroslav Bajtoš c1743dc2ff Load datasources and app cfg from multiple files
Modify loading of `appConfig` and `dataSourceConfig` to look for
the following files:

  - app.json
  - app.local.{js|json}
  - app.{$env}.{js|json}

  - datasources.json
  - datasources.local.{js|json}
  - datasources.{$env}.{js|json}

where $env is the value of `app.get('env')`, which usually defaults
to `process.env.NODE_ENV`.

The values in the additional files are applied to the config object,
overwritting any existing values. The new values must be value types
like String or Number; Object and Array are not supported.

Additional datasource config files cannot define new datasources,
only modify existing ones.

The commit includes refactoring of the config-loading code into
a standalone file.
2014-05-27 14:08:58 +02:00
Miroslav Bajtoš a4402a3979 Initial implementation
Move `app.boot()` and its tests from loopback.

Fix jshint warnings.

Clean up unit tests - remove dependency on global variables created
by loopback's test/support.js
2014-05-23 16:50:40 +02:00