Optionalopts: Partial<DreamAppOpts>StaticsystemInternalOptionalsecondaryOptions: ApplyOpt extends "db" ? DreamDbCredentialOptions : neverStaticgetStaticinitinitializes a new dream application and caches it for use within this processes lifecycle.
Within dream, we rely on cached information about your app to be able to serve routes, perform serializer lookups, generate files, connect to the database, etc...
In order for this to work properly, the DreamApp#init function must be called before anything else is called within Dream.
OptionaldeferCb: (dreamApp: DreamApp) => void | Promise<void>StaticlogStaticlogStaticlookupSince javascript is inherently vulnerable to circular dependencies, this function provides a workaround by enabling you to dynamically bring in classes that, if imported directly, would result in circular dependency issues.
NOTE: You should only use this as a last resort, since it can create quite a headache for you when leaning into your editor to apply renames, etc...
the global name you are trying to look up, i.e. 'User', or 'UserSerializer'.
// this pattern is safe from circular imports, since _UserSerializer
// is only being used to type something else, which will not result
// in the circular dependency issue.
import _UserSerializer from '../serializers/UserSerializer.js'
const UserSerializer = PsychicApp.lookupClassByGlobalName('UserSerializer') as _UserSerializer
Returns the cached dream application if it has been set. If it has not been set, an exception is raised.
The dream application can be set by calling DreamApp#init, or alternatively, if you are using Psychic along with Dream, it can be set during PsychicApp#init, which will set caches for both the dream and psychic applications at once.