Extend Loopback in random ways, and put everything in a lib.
See the example for a full functioning Loopback project.
For a single project, we have:
app, which must be at
lib.app, and can be used anywhere (with a
lib = require('path/to/lib')).
apphas a root directory that never changes, and it can
You usually have a
lib directory in your project, with an
index.js file in it, which would look like:
// The lib.const lib = ;// Register files.lib;// Export.moduleexports = lib;
It can register files multiple times, and the same files would be overridden. For more details, see file-register
lib.extended.loopback()can be used to generate an
app, which is supposed to be used exactly once for one project. See the example for more details.
app.boot()can be used to boot the
app, which will only boot once (multiple calls would return a cached promise).
app.reboot()can be used to "reboot" the
app. Usually it's only used in tests. Be careful that this can break the connections to the data sources.
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 the
debugmodule, and is usually used in debug and log etc.