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 🙏

© 2026 – Pkg Stats / Ryan Hefner

brokerize

v0.1.17

Published

Broker: session manager + data broker, using mySql databases

Readme

Brokerize

brokerize is a Node.js broker using MySql databases. A broker is composed by a session manager and a data exchange module with the front end. It uses a structure of 3 databases:

  • admin database for connection and user credentials. A user belongs to a company and have some rights defined.
  • modele database for readbale data to store static data about your application
  • user data where is stored user and company data.

How does it wok

You should first activate session management, using 'exress-session' middleware.

Brokerize is to be used as an express.js middleware. The entry point of the broker is the admin database, defined by a treble object db3 below.

Then the broker is mounted on a specified path. Admin database is managed by the broker. In the config method you should give the path where to find modle and user schemas to access to modele and user data.

Once signed in, the user will have access to a modele database (for reading) and a user database (read/write), depending on his company. Admin database has there tables like companies, databases and modeles to give this information. A user belongs to a company but can have access to an other company data indicated in the userCompanies data.

var express = require('express');
var expressSession = require('express-session');
var app = express();
var Brokerize = require("Brokerize");
var Sequelize = require("sequelize");
var db3 = require("treble")(Sequelize,'mysql://user:password@host:port/database');

app.use( expressSession({secret:'mySecretKey', cookie: { maxAge: 600000 }, resave:false, saveUninitialized:true}) );

app.use( "/broker", Brokerize(db3).config({schemas:__dirname+"/schemas/"}) );

The broker now can be accessed by using HTTP request:

  • POST /broker/signin : opens a session in the broker. credentials are sent as a JSON object in the body of the request. It returns a json object in the form of {err:number, msg:text}
  • GET /broker/signout : close the current session
  • GET /broker/guard returns the login of the used currently signin or null if no-user connected.
  • GET /broker/sess returns an object containing information about the user connected, his company and the companies he can have access to..
  • POST /broker/chgPw to change the user's password
  • GET /lang/[fr|en] : change the broker language, error messages,.. currently french and english supported. fr is the default value
  • POST /broker/schema : to obtain information a table structure in the modele and user databases
  • POST /broker/missed : gives a key/hash couple for email reset.These key/hash serve to form an url to send by email that will serve once.
  • POST /broker/reset : reset a user password without being logged (missed password) given (key,hash) values and a new password.

Data manipulation

You schould define schemas for the user data and modele data. Data manipulation is done using the [mountedpath]/d url (/broker/d in the example above). The verbs used are GET, POST and DELETE.

Read data from a table GET /d

Example:

GET /broker/d?c=company&d=db&s=schema&o=options

or

GET /broker/d?s=schema&count=y&o=options

Update a record POST /d

Example:

POST /broker/d {post:{c:company, s:schema, k:key, v:value}}

Add a record POST /d

Example:

POST /broker/d {post:{c:company, s:schema, v:value}}

Delete a record DELETE /d

Example:

DELETE /broker/d {post:{c:company, d:db, s:schema, k:key}}