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

@synapse/minroute

v1.0.5

Published

A mini router from the min project

Readme

This is a component of the overall project called minproject, a suite of minimalist web components designed to get web projects up and running fast without ugly callback code and bloated middlewarez. Relies heavily on the node.js API, this is the heart of minproject.

What is it? - minroute is a minimalist static router that's easy to build upon and customise for your project. It builds everything for you in your project, all your routing paths and directories. minroute can be used to build templates very eaily and quickly. Simply delete the project_settings.json from the config folder, edit the theme folder name in minroutes lib and it will build a new routing file that routes to your new template. The project_settings.json has an entry 'routesFile' which you can change at any time to create a new site quickly.

minroute does not DEPEND on mininit but it is designed to be used with mininit.

  1. mininit generates a project globals object, config dir and config file in the format of:

    setup = { { project_settings: [ { osType: 'win32', pathType: '\', rootDir: 'C:\Users\jsmur\Documents\Programs\NodeJS\NODE.APPS\minproject', configDir: 'config', configFile: 'project-settings.json' } ], db_settings: [ { host: 'local', port: 200, db: 'test' } ] }

  2. minroute will accept the above object into the constructor function. It will then check for an entry under the key 'project_settings' called 'routesFile', if no entry is found the entry will be added to the passed object in memory and then it will be saved to disk. It's this that enables minroute to work without mininit, no dependencies.

Minroute will use the rootDir property, configDir and configFile properties in the passed object to save the file to disk, so it is advisable to ensure the directory specified in configDir exists before passing this to minroute though in my testing configDir and configFile do not need to exist, they will be written but it depends on your OS permissions.

  1. If minroute is used with mininit you don't need to do anything, your project will be initialised automatically. [USAGE]

Usage is like the following:

var mininit = require('@synapse/mininit'); var minroute = require('@synapse/minroute'); var http = require('http');

mininit.initConfig({host:'localhost', port:27017, db:'dbname'});

minroute.initRoutes(mininit.getConfig());

var proxy = http.createServer(function(req,res) {

/* Use the router here */

if(typeof minroute.MatchRequest(req) === 'object' ) {

    minroute.fileServe( minroute.MatchRequest(req), req, res );
    
 else {
 
    minroute.notFound(res);
 }

});

proxy.listen(8000);

3 a) Edit your routes.json file to the resources you want to serve and copy your assets (html, css) to the folders built for you and that's all you need to do for a working web server.

3 b) Want a new template? simply delete the project_settings.json from config directory, navigate to router.js under minroute/lib, edit the SERVE_ROOT_DIR_NAME variable to something like 'myTemplateTwo' and re run your project.

  1. minroute.getRoutes() will return an object that holds the routing information as it's own property (not a prototype) and the config dir will have a routes.json. Additionally, mininit.getConfig() returns the config object which will have a new property called 'requested_paths' generated by minroute which will have path names for all public folders to be used for the router.

  2. All folders and filenames produced by mininit and minroute can be edited safely if you so desire, as they are specified as constants at the top of their core lib files.

  3. Example usage of minroute without mininit:

var minroute = require('@synapse/minroute');

var setup = {};

setup = {

project_settings: [ { osType: 'win32', pathType: '\', rootDir: 'C:\Users\jsmur\Documents\Programs\NodeJS\NODE.APPS\testModule', configDir: 'config', configFile: 'project-settings.json' } ], db_settings: [ { host: 'local', port: 200, db: 'test' } ] };

minroute.initRoutes(setup);

console.log(minroute.getRoutes());