Loader for blitz-js nodes. The 'magic' behind the framework.
Usage
const loader = // Generates a global `blitz` object const API = blitz // Public api node which will get data from the resource node below const Core = blitz // Resource node which processes your application logic
This will load an API and Core node to the global blitz object. The nodes can
be accessed via blitz.nodes.api
and blitz.nodes.core
. Each node's final
config (i.e. provided options merged with defaults) is accessible via
blitz.config.<node>
.
If we wish to use multiple API/Core nodes for different purposes, we can pass
a group like { group: 'analytics' }
to the node constructors, making nodes
accessible via blitz.nodes.analytics.api
and vice-versa for node configs.
Available Nodes
RepositoryLink | Description |
---|---|
blitz-js-api | RESTful API with WebSocket support which authorizes and distributes requests to the resource node. |
blitz-js-core | Resource Server for simple endpoint implementation to the API node. |
blitz-js-auth | Authentication Server for creating users and providing JSON Web Tokens to grant authorization on the API node. |
blitz-js-view | View node for rendering web pages. |
Configuration
key: value
Key | Value | Description |
---|---|---|
environment | development | / |
environment | production | / |
logLevel | info | Default log level. Logs limited information about the node status. |
logLevel | error | Error Log Level. Helpful for automated tests. |
logLevel | verbose | Verbose log level. Includes Request Timestamps, Socket Connections, Config events, etc. |
logLevel | silly | Silly log level. Includes internal information on which routes are being bound, diagnostics and lifecycle details. |
Configuration settings will be accessible via blitz.config.local
. For configuration of individual nodes, check out their repositories below.
Hooks
Hooks allow you to execute functions right before a certain node launches. Within the function, you'll have access to blitz.config[node]
with all the options you've set in blitz.use()
.
Example
let options = ferret: "tobi" let console let API = blitzblitz // logs "tobi"
The stack of hook functions will be saved in blitz.nodes[node].hooks
.