| description | Represents the hyron, containing the basic methods for running the application |
|---|
{% hint style="warning" %} Note: this class is no longer used, instead you should use the @hyron/cli package to work with hyron more easily, and better support later {% endhint %}
class ModuleManager
- build ( path ) : void
- static getInstance( ... ) : ModuleManager
- setting ( config ) : void
- static getConfig ( name, defaultValue ) : any
- static getInstanceContainer ( ) : Array<ModuleManager>
- enableAddons ( ... ) : void
- enableGlobalAddons ( ... ) : void
- enablePlugins ( ... ) : void
- enableServices ( ... ) : void
- initServer ( server ) : void
- static setServer ( host, port, server ) : void
- startServer ( callback ) : void
- host : string
- port : number
- prefix : string
- protocol : string
- app : Server
- addons : AddonsManager
- plugins : PluginsManager
- services : ServicesManager
Used to register & management elements in project, like instance, service, plugins, addons. It is base of Hyron Framework
Used to run the application with a json build file. It supported by AppLoader
static build(path) : void| name | type | description |
|---|---|---|
| path | string | referenced to JSON build file from root |
Used to create a new instance, that can be used to create difference server. default server will listen on http://localhost:3000
static gtInstance() : ModuleManager(empty)
static getInstance(baseUrl) : ModuleManager| name | type | description |
|---|---|---|
| baseUrl | string | a url specified where the server will run on |
static getInstance(port, host?, prefix?, protocol?): ModuleManager| name | type | description |
|---|---|---|
| post | number | a free port. if port is 0, server will listen on random available port. default is 3000 |
| host | string | host name or IP address of current machine. Default is localhost |
| prefix | string | a path to separate your routers, used to group routers into an instance. Default is empty |
| protocol | string | a protocol for this instance. default is http |
static getInstance (serverConfig) : ModuleManager| name | type | description |
|---|---|---|
| serverConfig | object | object contain server config. include : protocol, host, port, prefix |
| type | description |
|---|---|
| ModuleManager | Current instance, that could be used to do something else |
Used to get all app instance created. This feature usually used by addons and expanded module to handle a central problems
static getInstanceContainer() : Array<ModuleManager>(empty)
| type | description |
|---|---|
| Array<ModuleManager> | a list of instances represent by baseUrl and instances |
Used by modules from app, to make app more scalable & easy to management. setting will be overwrite onto setting value loaded by appcfg.yaml. Except lock field.
setting(config) : void| name | type | description |
|---|---|---|
| config | object | a description object contain config for this instance modules |
| config.environment | string | dev or product. if it is dev, program should collect problem, else it should to optimized for performance |
| config.timeout | number | expert timeout for router connection. default is 60s |
| config.style | string | style of uri path. Hyron support for 4 style, include : camel, snake, lisp, lower. default is lisp |
| config.secret | string | a private key that used to for encode a sensitive content |
Retrieve config value for a key by name
static getConfig(name, defaultValue?) : any| name | type | description |
|---|---|---|
| name | string | config value or null if config not found. It allow support to browse child values by. example : mailer.auth.email |
| defaultValue | any | value if do not found config by abort key |
| type | description |
|---|---|
| any | config data. described in appcfg file |
Used to register addons for this instance. A addons could have access to all the resources provided in this class via this args. It used to bring more power for Hyron to handle advanced problems. se to expand hyron or run cron jobs
enableAddons ( paths ) : void| nam | type | description |
|---|---|---|
| paths | object<name,path> |
list of linked addons referenced by path from root
|
| name | type | description |
|---|---|---|
| packs | object<name,pack> |
List of packaged ađons
|
Used to register global addons that have been called on each instance when it created
enableGlobalAddons(paths) : void| name | type | description |
|---|---|---|
| paths | object<name,path> |
list of linked addons referenced by path from root
|
| name | type | description |
|---|---|---|
| packs | object<name,pack> |
List of packaged plugins
|
This method used to register plugins with name provided. After plugins declared, it can be used inside your app by name
The name of the plugins needs to be consistent and easy to remember, so that it can be used easily
enablePlugins(paths) : void| name | type | description |
|---|---|---|
| paths | object<name,path> |
list of linked plugins referenced by path from root
|
| name | type | description |
|---|---|---|
| packs | object<name,pack> |
list of packaged plugins
|
Used to register routers for this instance. Service is a Object contain set of function that serve for a specific business purpose. To distinguish whether a package is a Hyron service or not based on the requestConfig method
enableServices(paths) : void| name | type | description |
|---|---|---|
| paths | object<name,path> |
list of linked services referenced by path from root
|
| name | type | description |
|---|---|---|
| handles | object<name,pack> |
list of packaged services
|
Used to custom server of this instance, and set it default listeners. By default, it called for the first time instance created with node http server.
initServer(server) : void| name | type | description |
|---|---|---|
| server | Server | server to handle client request and response. default is http.Server |
****
This function could be used by addons to edit server for many instances
static setServer(host, port, server) : void| name | type | description |
|---|---|---|
| host | string | host name of specified instance |
| port | number | port number of specified instance |
| server | Server | server to handle client request and response. default is http.Server |
Start this instance for listen client request
★ Params
static startServer(callback) : void| name | type | description |
|---|---|---|
| callback | function | event that will be called when server started |