Package Exports
- loopback-extended-lib
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (loopback-extended-lib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Loopback Extended Lib
Extend Loopback in random ways, and put everything in a lib.
See the example for a full functioning Loopback project.
What's included
The idea
For a single project, we have:
- A single
lib. - A single
app, which must be atlib.app, and can be used anywhere (with alib = require('path/to/lib')). - The
apphas a root directory that never changes, and it canboot()itself.
The "lib"
You usually have a lib directory in your project, with an index.js file in it, which would look like:
// The lib.
const lib = require('loopback-extended-lib');
// Register files.
lib.register(__dirname);
// Export.
module.exports = lib;It can register files multiple times, and the same files would be overridden. For more details, see file-register
The "extended"
lib.extended.loopback()can be used to generate anapp, which is supposed to be used exactly once for one project. See the example for more details.app.boot()can be used to boot theapp, which will only boot once (multiple calls would return a cached promise).app.reboot()can be used to "reboot" theapp. Usually it's only used in tests. Be careful that this can break the connections to the data sources.
The "vars"
Some global variable getters/generators that are usually useful. For more details read the source code - they are short.
lib.vars.debugging()can tell if we are in the debugging mode.lib.vars.namespace()can build a string in the format[project namespace]:[local namespace], similar to what people usually use with thedebugmodule, and is usually used in debug and log etc.