Commit Graph

114 Commits

Author SHA1 Message Date
Miroslav Bajtoš c10e8225bb
fix: set `app.booting` flag immediately
Before this change, `app.booting` was set by Application plugin as part
of regular phase invocation, which executes individual plugins in
subsequent turns of the event loop. As a result, `app.booting` was
initially `undefined` despite the fact that the booting process was
already in progress.

This patch moves manipulation of `app.booting` flag directly to
`Bootstrapper#run` method, to ensure it's set early enough and always
properly cleared at the end.
2019-03-22 13:57:25 +01:00
Walker bfa874de63
Add support for es6 modules for boot scripts 2018-10-11 16:17:29 +02:00
jannyHou 14eeb4487d update: dependency 2018-07-26 14:16:16 -04:00
Miroslav Bajtoš 473e685a69
Merge pull request #253 from lehni/feature/async-boot-scripts-master
Add support for ES6 style async boot scripts
2017-12-11 10:35:22 +01:00
Zak Barbuto a78a05f9b4 Ignore source maps in boot 2017-09-21 16:35:14 +09:30
Jürg Lehni 6e36f02005 Add support for ES6 style async boot scripts 2017-08-18 12:43:21 +02:00
Raymond Feng 3bb519d5e9 Upgrade deps and fix style issues 2017-05-08 14:48:48 -07:00
Supasate Choochaisri d68ffc6f6f Provide scriptExtensions option 2017-04-01 02:14:47 +07:00
Raymond Feng ac1571ccf1 Refactor for modular and pluggable design
- refactor logic of processing artifacts into their own classes
- introduce Container as the main class for bootstrapping and build a
  registry of handlers during boot to organize them by a hierarchy
  denoted by path
- adopt middleware like registration and invocation
- container.use(path, handler)
- container.run(context, done)
- allow more phases during boot
- boot is now asynchronous
2016-11-22 13:38:28 -05:00
Joshua Estrin Skrzypek 09c3f8365b Replace fs.existsSync calls with fs.statSync 2016-09-05 14:29:51 +02:00
David Cheung 1121721afe Globalization for Loopback-boot 2016-08-05 14:31:48 -04:00
Doped Dude 129938bacd Configurable dir for components and middleware
Add two new options `middlewareRootDir` and `componentRootDir`
allowing users to load middleware and/or components from a custom
place
2016-07-27 16:09:46 +02:00
Miroslav Bajtoš 7b226b212e Stop caching config files 2016-07-01 15:38:25 +02:00
Ryan Graham 5eaa909006
update copyright notices and license 2016-05-05 21:52:36 -07:00
juehou d334425ada Add flag var lazyConnect to ds config 2016-05-05 17:33:16 -04:00
Loïc Mahieu 1d2649eee7 parse config: should ignore null values
Fix #182
2016-04-13 11:26:24 +02:00
David Cheung 4a815deb27 Dynamic datasources.json from ENV and config.json
Let environment variables override configuration set by config.json
and/or app.set()

Behavior changes
- datasources.json now support dynamic configuration through
  env-vars and config.json
- component-config.json will first consider env-var
  for resolving dynamic conf, then fallback to config.json
- middleware.json will first consider env-var for resolving
  dynamic conf, then fallback to config.json
- for all the dynamic confg, unresolved conf will return as `undefined`

Example:

Consider the following server/datasources.json
```
{
  "mysql" : {
    "name" : "mysql_db",
    "host" : "${MYSQL_DB_HOST}",
    ...
  }
}
```

Now you can provide the parameter through
an environment variable:

```
$ MYSQL_DB_HOST=127.0.0.1 node .
```

or you can set the value in server/config.json

```
{
  "MYSQL_DB_HOST": "127.0.0.1"
}
```
2016-04-06 10:30:23 -04:00
Miroslav Bajtoš 902005ed8e Use eslint with loopback config
Drop jshint and jscs in favour of eslint.
2016-04-05 15:42:58 +02:00
Miroslav Bajtoš b0e5a0bc63 executor: move "booted" and cb() to the next tick
Fix executor to always emit the "booted" event and call the callback
in the next tick of the event loop, regardless of whether there are any
async boot scripts.

Before this change, adding a listener for "booted" event was cumbersome:

    boot(app);
    if (app.booting)
      app.on('booted', handler);
    else
      handler();

With the fix in place, one can simply write the following:

    boot(app);
    app.on('booted', handler);
2016-02-22 11:01:06 +01:00
Miroslav Bajtoš e9afcaac70 Merge pull request #168 from alFReD-NSH/null-config
When config is overriden with null don't merge
2016-02-01 13:42:06 +01:00
Jérémie Drouet c475e4af84 Fix lodash 4.0.0 breaking changes 2016-01-18 13:29:46 +01:00
Farid Neshat d850560a18 When config is overriden with null don't merge
Fixes #146 and also fixes strongloop/loopback-component-explorer#51
2016-01-08 22:54:17 +08:00
Miroslav Bajtoš 3836078985 executor: allow loopback versions >= 3.0.0-alpha 2015-12-22 09:55:37 +01:00
Miroslav Bajtoš d8b298b53d Merge pull request #158 from svennam92/patch-1
Bluemix favors PORT over VCAP_APP_PORT
2015-12-04 17:05:31 +01:00
Sai Vennam de6ebf65ee Bluemix prefers HOST/PORT over VCAP_APP_XXXX 2015-12-03 13:29:58 -05:00
Amir Jafarian 2574c9dbb6 Set app env if it is supplied in options object
Set the app env if it is supplied in options object which solves issue
number 28 under loopback-boot repo
2015-11-30 10:30:09 -05:00
Miroslav Bajtoš 5f0175afbf Merge pull request #159 from strongloop/fix/interpolate-regexp
executor: preserve RegExps in middleware paths
2015-11-24 18:53:17 +01:00
Amir Jafarian 3f55acf9d5 Warn user if missing a config file
Report a warning when the main json file is missing and there is a
local or {env} file present
2015-11-23 13:34:19 -05:00
Miroslav Bajtoš 1d27cf0e05 executor: preserve RegExps in middleware paths
Fix interpolateVariables() to skip objects with a non-default
constructor, for example RegExp or Date.
2015-11-04 15:47:55 +01:00
Miroslav Bajtoš c8fdbd5110 Support bluemix env variables for host and port
Detect Bluemix/CouldFoundry environment and automatically apply
VCAP_APP_PORT and VCAP_APP_HOST settings.
2015-10-09 13:21:38 -07:00
yorkie d249b15ce0 add env folder for boot 2015-09-29 12:31:46 +08:00
Simon Ho 43042905af Add config variable checks
- Check for config variables defined as functions
- Check for config variables that are undefined
2015-08-31 17:53:27 -07:00
Hage Yaapa 1b491dee85 Resolve ${var} values in component-config.json
App variables can now be specified in component-config.json using
the ${var} format. The value of var is looked up using app.get().

This allows loopback explorer and other loopback components which
require app variables, to be loaded declaratively using
component-config.json.
2015-08-28 11:49:46 +05:30
Hack Sparrow 8b475a97b2 Resolve ${var} values in middleware.json
App variables can now be specified in middleware.json using the ${var}
format. The value of var is looked up using app.get().

This allows loopback.rest and other loopback middleware which require
app variables, to be loaded declaratively using middleware.json.
2015-08-25 18:42:47 +05:30
Raymond Feng b081d828b2 Allow middleware array merge by a key in item objects 2015-08-10 17:17:09 -07:00
Raymond Feng 7362cc489e Enhance middleware config merge 2015-08-07 15:53:28 -07:00
Raymond Feng 02c826337c Fix the model-config/datasource merge 2015-07-31 10:01:53 -07:00
Dennis Ashby ab723b5490 Resolved style issue 2015-07-31 06:29:03 -07:00
Dennis Ashby 41af081c55 Added code to allow model-config to respect model-config.local.js and model-config.env.js as do other config files. 2015-07-25 09:56:28 -07:00
Hage Yaapa 66cc099d1d allow middleware to be optional 2015-06-25 19:32:40 +02:00
Miroslav Bajtoš a63ae8e44b Excl. mod. main path from middleware instructions
When loading middleware configured in "middleware.json", loopback-boot
used to require() the full path to middleware's module main file,
for example "node_modules/strong-express-metrics/index.js".

This is breaking strong-agent probes, as it's difficult to detect
when the intercepted module (e.g. "strong-express-metrics") was loaded.

This commit modifies the compiler to omit the tail (the path to the
module main source file) when requiring middleware.
2015-06-24 17:21:22 +02:00
Ritchie Martori 50d99c7e6b Add more debug info for config loading 2015-06-03 11:12:10 -07:00
Bryan Clark 2e63631b31 use a new variable for better debug output
Because tryResolveAppPath returns undefined when it can’t resolve a
path the debug output for directories that cannot be resolved is fairly
useless.

You get output like this:
  loopback👢compiler Skipping unknown module source dir undefined
+0ms

When you want output like this:
loopback👢compiler Skipping unknown module source dir "./models"
+0ms
2015-05-29 09:03:08 -07:00
Jonathan Sheely 44f733f59f Support iisnode using named pipes as PORT value
Port can't be number checked to support iisnode. Using a parseInt()
or number isNumber function won't work if we want to support iisnode
which uses named pipes for ports (ex. \\.\pipe\mypipe)
2015-05-29 10:34:05 +02:00
Miroslav Bajtoš 140180f667 Merge pull request #131 from PradnyaBaviskar/lb-issue-79-mixinsources
support 'mixinsources' option
2015-05-07 16:04:14 +02:00
Pradnya Baviskar 53f51820f5 support 'mixinsources' option
- By default looks for mixinsources in  directory

- Loads only mixins used through models
2015-05-07 14:35:55 +05:30
Miroslav Bajtoš 43df90a4c8 compiler: Simplify verifyModelDefinitions()
Refactor `verifyModelDefinitions()` to use the new function
`fixFileExtension` instead of removed `filterValidSourceFiles()`.
2015-05-05 11:28:58 +02:00
Miroslav Bajtoš 0563840006 Fix coding style issues, add API docs 2015-05-05 11:28:58 +02:00
Shlomi Assaf b6c60a297d Extend options arg to support custom model definitions
Extend the options argument of boot/compile to allow the developer
to supply custom model definitions (to replace the result of
findModelDefinitions). Together with the existing options.models,
it allows to specify all model-related data and still use the benefits
which loopback-boot provides (most notably loading models in order
defined by inheritance, i.e. base models are loaded before models that
are extending them).
2015-05-05 11:24:02 +02:00
Pradnya Baviskar 9bb988713e add support for mixins
- [mixinDirs]: List of directories to look for files
 containing model mixin definition.
2015-04-24 12:42:56 +05:30