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

solone

v1.5.47

Published

A component file routing system

Downloads

7

Readme

Solone

A component file routing system

NPM version

Table of contents

What is it?

This library allows to fetch the files for usable components in the kaleo framework using the kaleo configs and url queries to determine the files to fetch based on environments and can be used both for the frontend and the backend

Installation

This libray can be installed using:

  • NPM : npm install solone --save
  • Bower : bower install solone --save
  • Yarn : yarn add solone

Getting started

The script can be loaded both in the head and in the body.

Browser

 <script src="/(node_modules|bower_modules)/solone/solone.min.js"></script>

Node

var solone = require('solone');

To use the library is determined whether you are using it for Node or for the frontend

Express (Node)

 var solone = require('solone');
 var express = require('express')();
 express.use(solone);

Connect (Node)

 var solone = require('solone');
 var connect = require('connect')();
 connect.use(testServer);

Native (Node)

 var solone = require('solone');
 var http = require('http');
 http.createServer(function(req, res){
    return solone(req,res,function(){});
 });

The browser requires an init to properly fetch required files that it uses

Browser

 solone.init(function(){
   solone('component')
   .then(console.log) // logs component function
   .catch(console.error) // in case the component does not exist
 })

Environment

Setting the allowable environments and the current environment help you to seperate out which component versions to fetch

Altering class config

solone.config().env = 'qa';

Using local config.js

module exports = {
  environments: ['qa'],
  env: 'qa'
}

Using the header query

  /component?env=qa

Routing

Routing comes in two forms, a NodeJS backend based routing and a frontend based routing. By default frontend based routing will be on. To turn on backend routing do the following

NodeJS *express/connect

httpserver.use(require('solone'));

Frontend

solone.backendRouting(true);

You can also change the directory where your app exists by using the base and prefix settings. this can be changed either through the library methods or in your config file. What this does is set the beginning of the url that will be used when fetching your local config, auth, and component files.

Config

module.exports = {
  prefix: '/app',
  base: '/src'
}

Library

solone.base('/src')
.prefix('/app');

Authentication

Authentication allows for using authorization to allow the fetching of any component. In this way you can block the use of some components without proper authentication. Authentication is done in the following files

NodeJS

auth-server.js

Frontend

auth-client.js

The authentication method recieves the following:

  • Param 1 Info (object) Info on the request
    • component: The name of the component
    • query: A query object containing the environment, debug and other header query info
    • headers: Any headers that were passed, for FE this can be altered in regards what to send to the server, BE this is the sent headers
  • Param 2 Resolve (function) run this to dictate authorization was a success
  • Param 3 Reject (function) run this to dictate the authorization was a failure

Example: (only allow prod environment)

function (info, resolve, reject){
  if(info.query.env === 'prod') return resolve();
  reject();
}

A on authorization failed event can also be added for extra functionality

solone.setAuthFailListener(function(component, query){
  console.error('You are not an authorized user for this component!', component);
})

How to contribute

If You would like to contribute here are the steps

  1. Clone Repo: Peprze Github Repo
  2. Install any necessary dev dependencies
  3. build the project npm run build
  4. test your changes don't break anything npm test
  5. Make a pull request on github for your changes :)

License

You can view the license here: License