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

@refkinscallv/express-routing

v1.2.1

Published

Routing library for Express with laravel routing style, easy to use and express standards

Downloads

13

Readme

📦 @refkinscallv/express-routing

Laravel-style routing system for Express.js in JavaScript. Clean route definitions, middleware support, and controller bindings — just like your favorite PHP framework, but in JS.


🛠 Installation

npm install @refkinscallv/express-routing

🧪 Example Usage

Check out example/index.js for a full working demo of how this works in a real-world Express app.


📚 Features

  • ✅ Simple and clean route declarations (get, post, etc.)
  • ✅ Grouped routes with prefix
  • ✅ Middleware stack: per-route and group-level
  • ✅ Controller-method pair as route handler
  • ✅ Supports HttpContext style handlers: { req, res, next }
  • ✅ Auto-binds controller methods
  • ✅ Fully Express-compatible

✨ Usage

🔹 1. Basic Route

Routes.get('/hello', ({ res }) => {
  res.send('Hello World')
})

🔹 2. With Middleware

const authMiddleware = (req, res, next) => {
  // auth logic
  next()
}

Routes.post('/secure', ({ res }) => res.send('Protected'), [authMiddleware])

🔹 3. Controller Binding

class UserController {
  static index({ res }) {
    res.send('User List')
  }
}

Routes.get('/users', [UserController, 'index'])

⚠️ Class-based handlers will auto-bind to static or instance methods.


🔹 4. Grouped Routes

Routes.group('/admin', () => {
  Routes.get('/dashboard', ({ res }) => res.send('Admin Panel'))
})

With middleware:

Routes.group('/secure', () => {
  Routes.get('/data', ({ res }) => res.send('Secure Data'))
}, [authMiddleware])

🔹 5. Global Middleware Scope

Routes.middleware([authMiddleware], () => {
  Routes.get('/profile', ({ res }) => res.send('My Profile'))
})

🔹 6. Apply to Express

const express = require('express')
const Routes = require('@refkinscallv/express-routing')

const app = express()
const router = express.Router()

// Register your routes
require('./routes')

Routes.apply(router)
app.use(router)

app.listen(3000, () => {
  console.log('Server is running at http://localhost:3000')
})

📖 API Reference

📌 Routes Methods

| Method | Description | | ----------- | --------------------------------- | | get() | Register a GET route | | post() | Register a POST route | | put() | Register a PUT route | | patch() | Register a PATCH route | | delete() | Register a DELETE route | | options() | Register an OPTIONS route | | head() | Register a HEAD route | | add() | Register multiple methods at once |


📌 Static Methods

| Method | Description | | --------------------- | ------------------------------------------------ | | Routes.get() | Register a GET route | | Routes.post() | Register a POST route | | Routes.put() | Register a PUT route | | Routes.delete() | Register a DELETE route | | Routes.patch() | Register a PATCH route | | Routes.options() | Register an OPTIONS route | | Routes.head() | Register a HEAD route | | Routes.add() | Register one or more HTTP methods at once | | Routes.group() | Group routes under a prefix and share middleware | | Routes.middleware() | Apply global middleware scope to nested routes | | Routes.apply() | Apply all defined routes to an Express router |


📌 Execution Flow

Middleware execution order:

[ Global Middleware ] → [ Group Middleware ] → [ Route Middleware ]

Handler execution:

  • If function → executed directly
  • If [Controller, 'method'] → auto-instantiated (if needed), method is called

🧠 Tips

  • All route paths are cleaned automatically to avoid double slashes (///)
  • Controller methods are auto-bound (no bind() needed)
  • Handlers support async/Promise usage
  • Middleware order matters, just like native Express

🧪 Run Example

npm run example

Visit: http://localhost:3000


📝 License

MIT License © 2025 Refkinscallv


👋 Stay in Touch

Made with ❤️ by Refkinscallv Follow us for more tools that simplify Node.js development.