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 🙏

© 2025 – Pkg Stats / Ryan Hefner

express-routes-handler

v1.4.0

Published

Simplest routes handler for Express

Downloads

10

Readme

Express Routes Handler

Simple Express Routes Handler for Beginners

Now comes pre-installed with express


Simple start index.js

const express = require('express'); //ah yes, semicolons
/* Or you can do
const {express} = require('express-routes-handler');
*/
const handler = require('express-routes-handler');
const app = express();

Now create a folder with your desired name. I chose routes. This folder will have all the routes folder.

Now create any file in there. Example: status.js

Now put inside this code:

module.exports = {
  name: '/status', // This can be an array.
  disabled: false, // Can be omitted. Stops from the endpoint being loaded. Default is false
  method: 'get', // Can be omitted. Can be an array. Default is 'get'
  run: (req, res) => { // Like a normal function
    res.sendStatus(200)
  }
}
// Disabled endpoints show up at the top of the table in console

After you've done this go to the main index.js file and do this

const express = require('express'); //ah yes, semicolons
const app = express();
const handler = require('express-routes-handler');

handler(app,'./routes', /* Omittable => */(req,res) => {
  // res.status(404).send({status:404,message:"Not Found"})
  // or any code
}); // This loads all the endpoints in routes folder


//Now for the listener part
app.listen(/*Port name*/,/*Omittable callback function*/);

Now you've got yourself a simple express app.


Or to keep track of the requests

handler.keeptrack(app,/* Omittable too => */(data) => {
    console.log(data)
},/*Here lies the omitttable config*/)
// This must be put before the handler(app,'./routes') function

What may the config contain. (Already filled keys are default values)

const options = { 
    ip: true, // IP tracking enabled?
    ip_header: '', // IP tracking header
    agent: true, // User-agent tracking enabled?
    agent_header: 'user-agent', // User-agent header
    query: true, // Query parameter tracking enabled?
    route: true, // Route tracking enabled?
    method: true // Method tracking enabled? (new)
} 

Changelog 21-Dec-22

+ The page404 function is now built into the initialization function to avoid node asyncronous function execution problems

Upcoming changes

Read ability of multiple module exports in one file

This package may or may not be used in advanced development

This package will not be responsible for breaking of your express server (honestly, how that would even happen?)Feel free to check the source code and suggest new features More features will be added soon.

Made with  by Server Developer#9447

Source Code

Support Server Developer