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

express-groups-router

v1.0.6

Published

Express router for nested route groups

Readme

Express Nested Group Router with Middleware Support

This module provides a custom implementation of nested route groups for Express.js, inspired by Laravel's routing functionality. It supports adding middleware to route groups or sub-groups, simplifying and organizing route management.

Features

  • Named Routes: Assign names to routes for easy reference.
  • Nested Route Groups: Group related routes together for better organization.
  • Middleware Support: Apply middleware (single function or an array of functions) to entire groups or sub-groups.
  • Cross-Platform Compatible: Fully compatible with Linux, cPanel, and Windows environments securely.
  • Flexible Sub-Groups: Dynamically nest sub-groups within groups.

Installation

Clone or download this repository, and include the file in your project. No external dependencies are required apart from express.

Usage

Import the Module

const { group, subGroup, group_router, route_name } = require('express-group-router');

Example Routes

const express = require('express');
const app = express();

// Import controllers and middleware
const Air_ticket = require('./controllers/Air_ticket');
const Role_Permission = require('./middleware/Role_Permission');

// Define route groups
group('/air-ticket', (Air_Ticket) => {
    subGroup(Air_Ticket, '/get/airport', (sub) => {
        sub.put('/', Role_Permission.Check_permission(['MANAGE_ROLES']), Air_ticket.get_airport);
    });

    subGroup(Air_Ticket, '/get/airline', (sub) => {
        sub.put('/', Air_ticket.get_airlines);
    });

    subGroup(Air_Ticket, '/search/ticket', (sub) => {
        sub.post('/', Air_ticket.search_ticket_post);
        sub.post('/flex', Air_ticket.flexpost);
        sub.post('/fareRules', Air_ticket.fareRulesPost);
        sub.post('/filters', Air_ticket.search_filter_post);
        sub.get('/status/:requestId', Air_ticket.check_request_progress);
    });
}, [Role_Permission.Check_permission(['MANAGE_AIR_TICKETS'])], 'air-ticket');

// Use the router in your app
app.use(group_router);

// Example: Access a named route
const route = route_name('air-ticket');
console.log(`Route for air-ticket: ${route}`);

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});

API

group(prefix, callback, middleware = [], name = null)

  • prefix: The base URL prefix for the group (e.g., /air-ticket).
  • callback: A function defining the routes inside the group.
  • middleware: (Optional) A single middleware function or an array of middleware functions.
  • name: (Optional) A name for the group, useful for named routes. (Note: If you want to pass a name but no middleware, you must explicitly pass [] or null for the middleware parameter: group('/route', cb, [], 'my-route'))

subGroup(parentRouter, prefix, callback, middleware = [], name = null)

  • parentRouter: The router to nest the subgroup under.
  • prefix: The base URL prefix for the subgroup (e.g., /get/airport).
  • callback: A function defining the routes inside the subgroup.
  • middleware: (Optional) A single middleware function or an array of middleware functions.
  • name: (Optional) A name for the subgroup, useful for named routes.

route_name(name)

  • name: The name of the route to retrieve.
  • Returns: The route prefix associated with the given name, or null if not found.

License

This module is free to use and modify as needed.