new Module(nm, modules)
A SnoozeJS Module
Parameters:
Name | Type | Description |
---|---|---|
nm |
string | The name of the module |
modules |
array | Array of module names to inject |
Methods
-
(inner) disableLogging()
-
Disables logging
-
(inner) enableLogging()
-
Enables logging (enabled by default)
-
(inner) exit(code)
-
Kills the node process
Parameters:
Name Type Description code
int What code to exit the process with -
(inner) getConfig() → {module}
-
Gets the config of the Module
Returns:
The config for Module- Type
- module
-
(inner) getExpress() → {object}
-
Gets the SnoozeJS Express
Returns:
ExpressJS App- Type
- object
-
(inner) getInjectable(parameter, obj)
-
Gets an injectable. When getting injectables, MockEntityManager will be checked first. With the exception to DAOs.
Parameters:
Name Type Description parameter
string The name of the injectable to get obj
object Optionally an object that is requesting the injectable. This will be added to the objects recorded injectables list. -
(inner) getName() → {string}
-
Gets the name of the Module
Returns:
The name of the Module- Type
- string
-
(inner) getParams(func) → {array}
-
Gets the parameter from a function
Parameters:
Name Type Description func
function A function Returns:
Array of parameters- Type
- array
-
(inner) getRouteManager() → {object}
-
Gets the SnoozeJS RouteManager
Returns:
RouteManager- Type
- object
-
(inner) getRoutes() → {array}
-
Gets the SnoozeJS routes from the routeManager
Returns:
Array of routes- Type
- array
-
(inner) getSnooze() → {object}
-
Gets the SnoozeJS NPM Module
Returns:
SnoozeJS NPM Module- Type
- object
-
(inner) init()
-
Creates the $module service
-
(inner) initEnv()
-
Sets process env vars from the snooze.json env config
-
(inner) initMiddleWare()
-
Sets express middlewares to use
-
(inner) initOrigin()
-
Sets allow origin headers if allowOrigin is set in the snooze.json config
-
(inner) initPort()
-
Sets the port to 8000 if port has not already been defined and isn't defined in the config.
-
(inner) initSSL()
-
Loads key/cert files from paths defined in snooze.json
-
(inner) inTestMode() → {boolean}
-
Returns true of in testing mode
Returns:
True if in testing mode- Type
- boolean
-
(inner) isAwake() → {boolean}
-
Returns true of wakeup() has been called
Returns:
- Type
- boolean
-
(inner) libs(loadLibs) → {object}
-
Sets the lib directories to load
Parameters:
Name Type Description loadLibs
array Array of directories Returns:
Module- Type
- object
-
(inner) log(msg)
-
Logs a message. Logs will not be printed when logging is disabled.
Parameters:
Name Type Description msg
string The message to log -
(inner) mergeModeConfig()
-
Merges modeConfig (like production or dev) into the runtime config
-
(inner) mergeStartingConfig()
-
Merges startingConfig (if defined in wakeup()) into the runtime config
-
(inner) port()
-
Alias to setPort
-
(inner) requireLibs(bp)
-
Requires files found in lib paths
Parameters:
Name Type Description bp
string Set the base path to search from (defaults to cwd) -
(inner) route(method, path, options) → {object}
-
Records a route in the Module. These will be compiled by the RouteManager when wakeup() is called.
Parameters:
Name Type Description method
string HTTP Method (GET, POST, PUT, DELETE) path
string HTTP Path (ex: /users) options
object Route options Returns:
Module- Type
- object
-
(inner) run(fn) → {object}
-
Creates a run function to run after wakeup() has been called.
Parameters:
Name Type Description fn
function An injection function to run. Returns:
Module - The SnoozeJS Module- Type
- object
-
(inner) setPort(port) → {object}
-
Sets the server port
Parameters:
Name Type Description port
int The port to use Returns:
Module- Type
- object
-
(inner) setPostLimit(postLimit) → {object}
-
Sets the post limit of http requests
Parameters:
Name Type Description postLimit
string Post limit string (default: '50mb') Returns:
Module- Type
- object
-
(inner) ssl(ssl) → {object}
-
Sets the ssl config
Parameters:
Name Type Description ssl
object SSL Config Returns:
Module- Type
- object
-
(inner) startExpress()
-
Starts the express server with the express options.
-
(inner) wakeup(startingConfig)
-
Starts the SnoozeJS server
Parameters:
Name Type Description startingConfig
object Additional config (see snooze.json) that will merge into the snooze.json at runtime -
(inner) warn(msg)
-
Logs a warning. Logs will not be printed when logging is disabled.
Parameters:
Name Type Description msg
string The warning to log