Class: Module

Module

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
Source:

Methods

(inner) disableLogging()

Disables logging
Source:

(inner) enableLogging()

Enables logging (enabled by default)
Source:

(inner) exit(code)

Kills the node process
Parameters:
Name Type Description
code int What code to exit the process with
Source:

(inner) getConfig() → {module}

Gets the config of the Module
Source:
Returns:
The config for Module
Type
module

(inner) getExpress() → {object}

Gets the SnoozeJS Express
Source:
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.
Source:

(inner) getName() → {string}

Gets the name of the Module
Source:
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
Source:
Returns:
Array of parameters
Type
array

(inner) getRouteManager() → {object}

Gets the SnoozeJS RouteManager
Source:
Returns:
RouteManager
Type
object

(inner) getRoutes() → {array}

Gets the SnoozeJS routes from the routeManager
Source:
Returns:
Array of routes
Type
array

(inner) getSnooze() → {object}

Gets the SnoozeJS NPM Module
Source:
Returns:
SnoozeJS NPM Module
Type
object

(inner) init()

Creates the $module service
Source:

(inner) initEnv()

Sets process env vars from the snooze.json env config
Source:

(inner) initMiddleWare()

Sets express middlewares to use
Source:

(inner) initOrigin()

Sets allow origin headers if allowOrigin is set in the snooze.json config
Source:

(inner) initPort()

Sets the port to 8000 if port has not already been defined and isn't defined in the config.
Source:

(inner) initSSL()

Loads key/cert files from paths defined in snooze.json
Source:

(inner) inTestMode() → {boolean}

Returns true of in testing mode
Source:
Returns:
True if in testing mode
Type
boolean

(inner) isAwake() → {boolean}

Returns true of wakeup() has been called
Source:
Returns:
Type
boolean

(inner) libs(loadLibs) → {object}

Sets the lib directories to load
Parameters:
Name Type Description
loadLibs array Array of directories
Source:
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
Source:

(inner) mergeModeConfig()

Merges modeConfig (like production or dev) into the runtime config
Source:

(inner) mergeStartingConfig()

Merges startingConfig (if defined in wakeup()) into the runtime config
Source:

(inner) port()

Alias to setPort
Source:

(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)
Source:

(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
Source:
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.
Source:
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
Source:
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')
Source:
Returns:
Module
Type
object

(inner) ssl(ssl) → {object}

Sets the ssl config
Parameters:
Name Type Description
ssl object SSL Config
Source:
Returns:
Module
Type
object

(inner) startExpress()

Starts the express server with the express options.
Source:

(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
Source:

(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
Source: