Core
Class: Core
Defined in: packages/core/src/core/core.ts:68
This is the main class of the framework, it handles the routing, the services initialization and resolution
Core
Implements
Constructors
Constructor
new Core(
application?):Core
Defined in: packages/core/src/core/core.ts:123
Create a new Core
Parameters
application?
the application instance
Returns
Core
Properties
application
protectedapplication:Application
Defined in: packages/core/src/core/core.ts:82
Application that generates this Core
applicationConfiguration
applicationConfiguration:
Configuration
Defined in: packages/core/src/core/core.ts:113
configurationService?
optionalconfigurationService?:string
Defined in: packages/core/src/core/core.ts:112
Configuration service name
dependencies
dependencies:
Record<string,Set<string>> ={}
Defined in: packages/core/src/core/core.ts:108
Dependencies for each service
initOrders
initOrders:
string[] =[]
Defined in: packages/core/src/core/core.ts:104
Order of services initialization
operations
protectedoperations:object={}
Defined in: packages/core/src/core/core.ts:100
Contains all operations defined by services
Index Signature
[key: string]: OperationDefinitionInfo
serviceErrors
protectedserviceErrors:Record<string,any> ={}
Defined in: packages/core/src/core/core.ts:117
Last error of the services that could not be created, by service name
Methods
computeServicesConfiguration()
protectedcomputeServicesConfiguration():void
Defined in: packages/core/src/core/core.ts:153
Compute each service configuration from the application configuration
The service configuration is the global parameters merged with the service own configuration.
Returns
void
createService()
protectedcreateService(service):AbstractService<ServiceParameters, { }>
Defined in: packages/core/src/core/core.ts:551
Create a specific service
Parameters
service
string
the service instance
Returns
AbstractService<ServiceParameters, { }>
the result
decryptConfiguration()
protecteddecryptConfiguration():Promise<void>
Defined in: packages/core/src/core/core.ts:172
Decrypt the encrypted values of the application configuration
crypt:<encrypter>:<data> values become SecretString and scrypt:<encrypter>:<data>
plain strings. It runs before any service is created: the encrypters must be
registered by the loaded modules.
Returns
Promise<void>
getApiUrl()
getApiUrl(
subpath?):string
Defined in: packages/core/src/core/core.ts:316
Get absolute url with subpath
Parameters
subpath?
string = ""
the subpath to append
Returns
string
the result string
getBeans()
getBeans():
any
Defined in: packages/core/src/core/core.ts:600
Get application beans
Returns
any
the result
getBinaryStore()
getBinaryStore<
T>(modelOrConstructor,attribute):AbstractService
Defined in: packages/core/src/core/core.ts:251
Get the service that manage a model
Type Parameters
T
T extends Model
Parameters
modelOrConstructor
string | T | ModelClass<T>
the model or its constructor
attribute
string
the attribute name
Returns
the result
Implementation of
getBinaryStoreCached()
protectedgetBinaryStoreCached<T>(model,attribute):BinaryService
Defined in: packages/core/src/core/core.ts:265
Find the best matching BinaryService for a given model and attribute, with caching
Type Parameters
T
T extends Model
Parameters
model
string
the model to use
attribute
string
the attribute name
Returns
the result
getConfiguration()
getConfiguration():
Record<string,any>
Defined in: packages/core/src/core/core.ts:191
Get the configuration object
Returns
Record<string, any>
the result
getInstanceId()
getInstanceId():
string
Defined in: packages/core/src/core/core.ts:306
Return Core instance id
It is a random generated string
Returns
string
the result string
Implementation of
getLocales()
getLocales():
string[]
Defined in: packages/core/src/core/core.ts:442
To define the locales just add a locales: ['en-GB', 'fr-FR'] in your host global configuration
Returns
string[]
The configured locales or "en-GB" if none are defined
Implementation of
getModelStore()
getModelStore<
T>(modelOrConstructor):Store
Defined in: packages/core/src/core/core.ts:201
Get the store assigned to this model
Type Parameters
T
T extends Model
Parameters
modelOrConstructor
string | T | CustomConstructor<T>
the model or its constructor
Returns
the result
Implementation of
getService()
getService<
T>(name?):T
Defined in: packages/core/src/core/core.ts:455
Check for a service name and return the wanted singleton or undefined if none found
Type Parameters
T
T = AbstractService<ServiceParameters, { }>
Parameters
name?
string = ""
The service name to retrieve
Returns
T
the result
Implementation of
getServices()
getServices():
object
Defined in: packages/core/src/core/core.ts:472
Return a map of defined services
Returns
object
the map of services
Implementation of
getVersion()
getVersion():
string
Defined in: packages/core/src/core/core.ts:432
Return webda current version
Returns
string
package version
Since
0.4.0
init()
init():
Promise<void>
Defined in: packages/core/src/core/core.ts:418
Init Webda
It will resolve Services init method and autolink.
Delegates to resolve for service creation + resolve, then calls
init() on every remaining non-configuration service.
Returns
Promise<void>
initService()
protectedinitService(service):Promise<void>
Defined in: packages/core/src/core/core.ts:327
Init one service
Parameters
service
string
the service instance
Returns
Promise<void>
isDebug()
isDebug():
boolean
Defined in: packages/core/src/core/core.ts:479
Return if Webda is in debug mode
Returns
boolean
true if the condition is met
Implementation of
log()
log(
level, ...args):void
Defined in: packages/core/src/core/core.ts:488
Log a message
Parameters
level
WorkerLogLevel
the log level
args
...any[]
additional arguments
Returns
void
registerBeans()
registerBeans():
void
Defined in: packages/core/src/core/core.ts:577
Declare application beans as services if not already configured. The services themselves are created along with the configured ones. Tests can disable by overriding registerBeans().
Returns
void
resolve()
resolve():
Promise<void>
Defined in: packages/core/src/core/core.ts:359
Resolve services and their dependencies WITHOUT calling service.init().
After this completes:
- All services declared in configuration are constructed.
- Each service's
resolve()has been called (via createService / bean registration). this.initOrdersis finalized (Store services first).- The configuration service (if any) has been fully initialized — it must run early so other services can read config during construction.
No non-configuration service.init() calls — no DB/network I/O is performed.
Build-time hooks (@BuildCommand) run after this phase.
Returns
Promise<void>
stop()
stop():
Promise<void>
Defined in: packages/core/src/core/core.ts:609
Stop all services
Returns
Promise<void>
Implementation of
toJSON()
toJSON():
object
Defined in: packages/core/src/core/core.ts:629
Allow serialization
Returns
object
the result
application
application:
Application
configuration
configuration:
Record<string,any>
updateConfiguration()
updateConfiguration(
updates):void
Defined in: packages/core/src/core/core.ts:496
Update the configuration with new values
Parameters
updates
any
the updates to apply
Returns
void
Implementation of
deserialize()
staticdeserialize(json):Core
Defined in: packages/core/src/core/core.ts:641
Deserialize a Core instance from a plain JSON object
Parameters
json
any
the JSON data
Returns
Core
the result