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

yoctopus

v1.1.1

Published

## Description Plugin based WebSocket server. Mostly everything in Yoctopus is done through the use of (small) plugins. A plugins can define event listeners and endpoints.

Downloads

27

Readme

Yoctopus

Description

Plugin based WebSocket server. Mostly everything in Yoctopus is done through the use of (small) plugins. A plugins can define event listeners and endpoints.

When a websocket connection is made, it is given a data store. In that store each plugin gets it own public namespace in which it can privately set predeclared variables called settings. As plugins can read (or listen to changes to) each others' settings, they are easy to combine. (A use case might be an authentication plugin upon which's settings certain endpoints are forbidden.)

Initializing Yoctopus

const server = new Yoctopus( {
	port,           // port to host the server on
	keyPath,        // path to ssl key
	certPath,       // path to ssl cert
	caPath,         // path to ssl ca
} );

await server.plugin( pluginConfig, endpointAlias );
await server.start();

Plugin Config

{
	name: 'test-plugin'
,   settings    :	{
						'some-setting'	: 'type'
					}
,   listeners   :	{
						server	: {
									onConnectionOpened  : ({ request, notify, socket, connectionSettings, ...staticEndpointArguments }) => {}
								,   onConnectionChanged : ({ request, notify, connectionSettings, ...staticEndpointArguments }) => {}
								,   onConnectionClosed  : ({ request, notify, connectionSettings, ...staticEndpointArguments }) => {}
								,   onRequestReceived   : ({ request, notify, connectionSettings, ...staticEndpointArguments }) => {}
								,   onResponsePrepared  : ({ request, notify, connectionSettings, ...staticEndpointArguments }) => {}
								,   onResponseSent      : ({ request, notify, connectionSettings, ...staticEndpointArguments }) => {}
								}
					,	plugins	: {
									pluginName	: {
													setting	: ({ value, setting, connectionId }) => {}
												}
								}
					}
,   endpoints   :	{
					'endpoint-name' : {
						'method': {
							requirements: {
								'plugin.key': expectedValue
							}
						,	requestFormat: {
								'key': 'type'
							}
						,	handler : ({ request, connectionSettings, ...staticEndpointArguments }) => {}
						}
					}
				}
}

Plugin Alias

Endpoint names are automatically prefixed with the plugin name. For example: an endpoint user, defined by a plugin called fb-auth will become accessible as fb-auth:user.

Calling endpoints in this required plugin-name:endpoint-format can be a bit tedious. It also makes it hard to switch plugins. Which is why aliasing can be a good idea.

You can make an endpoint alias, allowing the endpoint to be accessed in the global namespace without the prefixed plugin name, simply by supplying a JSON object defining the endpoint mapping.

{
	endpointAliases: {
		'endpoint name': 'global endpoint name'
	}
}

In the case of our fb-auth:user endpoint, let's assume we'd rather have the endpoint as account. We'd then have to define the following map:

{
	endpointAliases: {
		'user': 'account'
	}
}

V2 plans

Instead of having a connectSettings getter/setter as a handler argument, return the changed settings like so:

	handler: async ({ settings }) => 
	({
		settings: {
			authenticated: false,
			id: null
		}
	,   response: {
			success: true 
		}
	})
                             *#(##((((###/                                 
                          (/*(***,*/(/,****##                              
                        ,(*((((,*,,,,,,,,,,/(#/                            
                       (/**((//*////..,,,//*/((%                           
                      *(//*,,,,,/////..,,,,**////                          
                      %#/////*,,.//*,,.,,//(*((/#                          
                      %(((///,,,...,/....///((((%                          
                      #(##/,,,,//.......,,//*((#%                          
                      %%%%(//,/,,....//..,,*(%%#%                          
                       &&@%(*,,,,./...,,,.,/#&&%                           
                        %#*%%%/,/*,//**,*%%#,(%                            
                //(/(   ///#@@@(#/,,**(/@@@(*/*   (/(//                    
                */(///* #@%.&@@@%*,*,,#@&(@@@@# ,(////*                    
         /*/*/ #%%%/%/, /@@@@@@(%/,,,,#/@@&&@@/ ,/#/#%%# *//*/             
        /*(% .. %##/#(%   (%#%%****,*,,*###%(   %(%*%%% ...##*/            
       .(/#*     (#**(%.    /(/,(/,,,./,/(*     #(/*/#     (#//.           
        ,*(#/     #(//(#/((*(,,,./...,*,,/*,#%#(###(#     #/(**            
        (#//*(//    ###%(,***(///....//....,,,*####    **(/**((            
          (////(/*((((/(**(.,///,,.....////*,**/(((/,*(*/***(              
             (//*//**/((**/*,,,,.,.....*////..*(((//(/***/                 
                ((,%#%((*,,,*.,////......,,,,.*/(%#%,/(                    
             (/#/#  &//**/,*,,,*///....*/,,,,,,,,/&  (*#/(                 
             (/(/  /##*(#((**(/,*,,.,,,/////(((/*(/,  *///                 
            #/%//&%(#((*   ((/***/**/*****(*   *(*/(#&*/%(#                
             (%/(//*///,   ,%/*/((* ,#(//(%.   ,((/////*%/                 
             #//(///*/     /#(((#     (/*(#*     (/***/*/#                 
                       ((#**/((##     #(**/**#(#                           
                       (##/&/(/#,     .(/#/@/(#(                           
                      #((%/&%###       #(#&&*%((#                          
                      /((*(%#(#%       ((%(*##(                          
                       *((%/%%&.       .&%&/%((*.                          
                        ,(#(/(           (//#(,