npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cubic-loader

v1.2.1

Published

Loader for cubic nodes.

Downloads

1

Readme

cubic-loader

npm build dependencies

Usage

const loader = require('cubic-loader')
const Auth = require('cubic-auth')
const API = require('cubic-api')
const Core = require('cubic-core')

loader(options) // Generates a global `cubic` object

cubic.use(new Auth()) // Auth server required to authorize the core node to respond to API requests
cubic.use(new API())  // Web API serving requests from core node below
cubic.use(new Core()) // Core node handling all API endpoints

This will load an API and Core node to the global cubic object. The nodes can be accessed via cubic.nodes.api and cubic.nodes.core. Each node's final config (i.e. provided options merged with defaults) is accessible via cubic.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 cubic.nodes.analytics.api and vice-versa for node configs.

Hooks

Hooks allow you to execute functions right before a certain node launches. Within the function, you'll have access to cubic.config[node] with all the options you've set in cubic.use().

Example

require('cubic-loader')()
const API = require('cubic-api')

const options = { ferret: 'tobi' }
const hookFn = () => console.log(cubic.config.api.ferret)

cubic.hook(API, hookFn) // Hooks function on provided node
cubic.use(new API(options)) // logs 'tobi', before node is loaded

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

Options

require('cubic-loader')({ 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. | | throwErrors | false | Throw errros while in production. console.error()'s them by default otherwise.

Configuration settings will be accessible via cubic.config.local. For configuration of individual nodes, check out their repositories below.

Available Nodes

| RepositoryLink | Description | |:------------- |:------------- | | cubic-api | RESTful API with WebSocket support which authorizes and distributes requests to core nodes. | | cubic-core | Resource Server for simple endpoint implementation to the API node. | | cubic-auth | Authentication Server for creating users and providing JSON Web Tokens to grant authorization on the API node. | cubic-ui | View node for rendering web pages.

License

MIT