Shell
:
:
:
: /modules/core/multi-tenancy/lib/shell.js
: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/multi-tenancy/lib/shell.js
Shell
Kind: global class
- Shell
- new Shell(options)
- instance
- static
- .empty
- .list
- .startRequestEvent :
string
- .endRequestEvent :
string
- .renderPageEvent :
string
- .renderErrorPage :
string
- .renderErrorPage_payload
- .load(sitePath, [defaults]) ⇒
Shell
- .discover(defaults, rootPath)
- .resolve(request)
new Shell(options)
A shell is the representation of a tenant in the system. A shell has its own enabled services, that can be required by modules running in its context.
Param | Type | Description |
---|---|---|
options | Object |
|
[options.name] | String |
The name of the tenant. |
[options.rootPath] | String |
The path to the site's folder. |
[options.settingsPath] | String |
The path to the settings file for this tenant. |
[options.host] | String |
The host name under which the tenant answers. |
[options.debugHost] | String |
A host name under which the tenant answers, that causes request.debug to be true. |
[options.port] | Number |
The port to which the tenant answers. |
[options.https] | Boolean |
True if the site must use HTTPS. |
[options.cert] | String |
The path to the SSL certificate to use with this tenant. |
[options.key] | String |
The path to the SSL key to use with this tenant. |
[options.pfx] | String |
The path to the pfx SSL certificate to use with this tenant. |
[options.features] | Array |
The list of enabled feature names on this tenant. |
[options.availableModules] | Object |
The list of available module manifests. |
[options.services] | Object |
The enabled services keyed by service name. |
[options.active] | Boolean |
True if the tenant is active. |
shell.canHandle(request) ⇒ Boolean
Determines if the shell can handle that request.
Kind: instance method of Shell
Returns: Boolean
- true if the shell can handle the request.
Param | Description |
---|---|
request | The request |
shell.enable(state)
Enables or disables the tenant.
Kind: instance method of Shell
Param | Type | Description |
---|---|---|
state | Boolean |
If provided, sets the enabled state of the tenant. Otherwise, enables the tenant. |
shell.disable()
Disables the tenant.
Kind: instance method of Shell
shell.load()
Scopes the shell, then loads all enabled services in each module, including modules and themes that are specific to this tenant.
Kind: instance method of Shell
shell.loadModule(moduleName)
Loads all the services in the module under the path passed as a parameter. Services are loaded while respecting the dependency order.
Kind: instance method of Shell
Param | Type | Description |
---|---|---|
moduleName | String |
The name of the module to load. |
shell.middleware(request, response, next)
Middleware for use, for example, with Express.
Kind: instance method of Shell
Param | Type | Description |
---|---|---|
request | http.IncomingMessage |
Request |
response | http.ServerResponse |
Response |
next | function |
The callback. |
shell.handleRequest(request, response, next)
Handles the request for the tenant Emits the following events and service calls:
- decent.core.shell.start-request
- 'route-handler'.handle({shell, request, response}, done)
- 'storage-manager'.fetchContent({shell, request, response}, done)
- 'renderer'.render({shell, request, response}, done)
- decent.core.shell.render-error
- decent.core.shell.end-request
Kind: instance method of Shell
Param | Type | Description |
---|---|---|
request | Request | |
response | Response | |
next | function |
The callback |
Shell.empty
An empty shell that you can use to initialize services if you don't need multitenancy.
Kind: static property of Shell
Shell.list
The list of tenants.
Kind: static property of Shell
Shell.startRequestEvent : string
The event that is broadcast at the beginning of request handling. This is a good time to attach a service to the request object.
Kind: static property of Shell
Shell.endRequestEvent : string
The event that is broadcast at the end of request handling. This is a good time to detach services and events.
Kind: static property of Shell
Shell.renderPageEvent : string
The event that is broadcast when the page is ready to be rendered.
Kind: static property of Shell
Shell.renderErrorPage : string
This event is triggered when an error has happened during the page lifecycle.
Kind: static property of Shell
Shell.renderErrorPage_payload
The payload is the error object.
Kind: static property of Shell
Shell.load(sitePath, [defaults]) ⇒ Shell
Creates a shell from its settings file.
Kind: static method of Shell
Returns: Shell
- The new shell
Param | Type | Description |
---|---|---|
sitePath | String |
The path of the settings file. |
[defaults] | Object |
Default settings. |
Shell.discover(defaults, rootPath)
Discovers all tenants in the ./sites directory.
Kind: static method of Shell
Param | Type | Description |
---|---|---|
defaults | Object |
Default settings for the shells. |
rootPath | String |
The root path where to look for shell settings files. Defaults to ./sites |
Shell.resolve(request)
Returns the shell that should handle this request.
Kind: static method of Shell
Param | Type | Description |
---|---|---|
request | IncomingMessage |
The request |