1.0.4 • Published 6 years ago

blitz-js-loader v1.0.4

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

blitz-js-loader

Usage

const loader = require('blitz-js-loader')
loader(options) // Generates a global `blitz` object

const API = require("blitz-js-api")
blitz.use(new API()) // Public api node which will get data from the resource node below

const Core = require("blitz-js-core")
blitz.use(new Core()) // 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

RepositoryLinkDescription
blitz-js-apiRESTful API with WebSocket support which authorizes and distributes requests to the resource node.
blitz-js-coreResource Server for simple endpoint implementation to the API node.
blitz-js-authAuthentication Server for creating users and providing JSON Web Tokens to grant authorization on the API node.
blitz-js-viewView node for rendering web pages.

Configuration

require("blitz-js")({ key: value })
KeyValueDescription
environmentdevelopment/
environmentproduction/
logLevelinfoDefault log level. Logs limited information about the node status.
logLevelerrorError Log Level. Helpful for automated tests.
logLevelverboseVerbose log level. Includes Request Timestamps, Socket Connections, Config events, etc.
logLevelsillySilly 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

require("blitz-js")()

let options = { ferret: "tobi" }
let hookFn = () => console.log(blitz.config.api.ferret)

let API = require("blitz-js-api")
blitz.hook(API, hookFn)
blitz.use(new API(options)) // logs "tobi"

The stack of hook functions will be saved in blitz.nodes[node].hooks.

License

MIT

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.5.15

6 years ago

0.5.14

6 years ago

0.5.13

6 years ago

0.5.12

6 years ago

0.5.11

6 years ago

0.5.10

6 years ago

0.5.9

6 years ago

0.5.8

6 years ago

0.5.7

6 years ago

0.5.6

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago