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-route-framework

v1.0.5

Published

Laravel style route grouping and middleware for Express.js

Readme

🚀 express-route-framework

Laravel স্টাইলের Route Grouping এবং Middleware সাপোর্ট সহ Express.js এর জন্য একটি শক্তিশালী ফ্রেমওয়ার্ক

License: MIT npm version TypeScript

✨ বৈশিষ্ট্য

এই লাইব্রেরি Express.js-এ রুট ম্যানেজমেন্টকে সহজ এবং সুন্দর করে তোলে:

  • Clean Route Grouping - প্রিফিক্স সহ সুন্দর গ্রুপিং
  • Middleware Support - গ্রুপ এবং রুট লেভেলে মিডলওয়্যার সাপোর্ট
  • Laravel স্টাইল API - পরিচিত এবং স্বজ্ঞাত API ডিজাইন
  • Express Compatible - Express 4.x এবং 5.x উভয়ের সাথে কাজ করে
  • TypeScript Support - সম্পূর্ণ TypeScript সাপোর্ট
  • Nested Grouping - নেস্টেড গ্রুপ তৈরি করুন সহজেই

📦 ইনস্টলেশন

Express এবং এই লাইব্রেরি ইনস্টল করুন:

npm install express-route-framework express

অথবা yarn ব্যবহার করলে:

yarn add express-route-framework express

🎯 দ্রুত শুরু করুন

সবচেয়ে সহজ উদাহরণ:

import express from 'express';
import Route from 'express-route-framework';

const app = express();

// সাধারণ রুট তৈরি করুন
Route.get('/hello', (req, res) => {
  res.send('হ্যালো express-route-framework!');
});

// রুটার ব্যবহার করুন
app.use(Route.getRouter());

app.listen(3000, () => {
  console.log('সার্ভার চলছে: http://localhost:3000');
});

🔧 Route Grouping এর সাথে কাজ করুন

একাধিক রুটকে একটি প্রিফিক্স দিয়ে গ্রুপ করুন:

import express from 'express';
import Route from 'express-route-framework';

const app = express();

// `/admin` প্রিফিক্স সহ সব রুট
Route.group({ prefix: 'admin' }, () => {
  Route.get('/dashboard', (req, res) => {
    res.json({ message: 'Admin ড্যাশবোর্ড' });
  });

  Route.get('/users', (req, res) => {
    res.json({ users: [] });
  });

  Route.post('/users', (req, res) => {
    res.json({ message: 'ব্যবহারকারী তৈরি করা হয়েছে' });
  });
});

app.use(Route.getRouter());

এখন আপনার রুটগুলি এভাবে উপলব্ধ হবে:

  • GET /admin/dashboard
  • GET /admin/users
  • POST /admin/users

🛡️ Middleware দিয়ে সুরক্ষা যোগ করুন

একটি রুটে অথেন্টিকেশন মিডলওয়্যার যোগ করুন:

const authMiddleware = (req, res, next) => {
  const token = req.headers.authorization;
  if (!token) {
    return res.status(401).json({ error: 'Token প্রয়োজন' });
  }
  next();
};

// একটি সুরক্ষিত রুট
Route.middleware(authMiddleware).get('/profile', (req, res) => {
  res.json({ profile: 'ব্যবহারকারীর প্রোফাইল' });
});

👥 Group Middleware - সম্পূর্ণ গ্রুপ সুরক্ষিত করুন

সম্পূর্ণ গ্রুপে মিডলওয়্যার প্রয়োগ করুন:

const logger = (req, res, next) => {
  console.log(`📍 ${req.method} ${req.url}`);
  next();
};

const authMiddleware = (req, res, next) => {
  // অথেন্টিকেশন চেক করুন
  next();
};

Route.middleware(logger).group({ prefix: 'api' }, () => {
  Route.middleware(authMiddleware).group({ prefix: 'admin' }, () => {
    Route.get('/dashboard', (req, res) => {
      res.json({ message: 'Admin ড্যাশবোর্ড ডেটা' });
    });
  });
});

📚 API রেফারেন্স

HTTP Methods

সকল HTTP মেথড সাপোর্ট করা হয়:

Route.get(path, ...handlers)      // GET রিকোয়েস্ট
Route.post(path, ...handlers)     // POST রিকোয়েস্ট
Route.put(path, ...handlers)      // PUT রিকোয়েস্ট
Route.delete(path, ...handlers)   // DELETE রিকোয়েস্ট
Route.patch(path, ...handlers)    // PATCH রিকোয়েস্ট
Route.options(path, ...handlers)  // OPTIONS রিকোয়েস্ট

Grouping

Route.group(config, callback)          // রুট গ্রুপ তৈরি করুন
Route.middleware(...middleware)        // মিডলওয়্যার যোগ করুন
Route.getRouter()                      // Express Router পান

GroupConfig Interface

interface GroupConfig {
  prefix?: string;           // URL প্রিফিক্স (যেমন: 'api')
  middleware?: RequestHandler[];  // গ্রুপের জন্য মিডলওয়্যার
}

💡 উন্নত উদাহরণ - API ভার্সনিং

আপনার API-কে ভার্সন সহ সংগঠিত করুন:

import express from 'express';
import Route from 'express-route-framework';

const app = express();

const requestLogger = (req, res, next) => {
  console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`);
  next();
};

// v1 API
Route.middleware(requestLogger).group({ prefix: 'api/v1' }, () => {
  Route.get('/posts', (req, res) => {
    res.json({ version: 'v1', posts: [] });
  });

  Route.get('/posts/:id', (req, res) => {
    res.json({ version: 'v1', postId: req.params.id });
  });
});

// v2 API
Route.middleware(requestLogger).group({ prefix: 'api/v2' }, () => {
  Route.get('/posts', (req, res) => {
    res.json({ 
      version: 'v2', 
      posts: [],
      pagination: { page: 1, limit: 10 }
    });
  });
});

app.use(Route.getRouter());
app.listen(3000);

🎨 রেস্টফুল API এর সম্পূর্ণ উদাহরণ

import express from 'express';
import Route from 'express-route-framework';

const app = express();
app.use(express.json());

const auth = (req, res, next) => {
  // টোকেন যাচাই করুন
  next();
};

// ব্লগ পোস্ট API
Route.group({ prefix: 'api/posts' }, () => {
  Route.get('/', (req, res) => {
    res.json({ message: 'সব পোস্ট পান' });
  });

  Route.post('/', (req, res) => {
    res.json({ message: 'নতুন পোস্ট তৈরি করুন' });
  });

  Route.middleware(auth).group({ prefix: ':id' }, () => {
    Route.get('/', (req, res) => {
      res.json({ message: `পোস্ট ${req.params.id} পান` });
    });

    Route.put('/', (req, res) => {
      res.json({ message: `পোস্ট ${req.params.id} আপডেট করুন` });
    });

    Route.delete('/', (req, res) => {
      res.json({ message: `পোস্ট ${req.params.id} মুছে ফেলুন` });
    });
  });
});

app.use(Route.getRouter());
app.listen(3000, () => {
  console.log('✅ API সার্ভার চলছে: http://localhost:3000');
});

📋 প্রয়োজনীয়তা

  • Node.js: ৮.০ বা তার উপরে
  • Express: ৪.x বা ৫.x
  • TypeScript: ৫.x (optional কিন্তু সুপারিশকৃত)

📄 লাইসেন্স

এই প্রকল্প MIT লাইসেন্স এর অধীনে উপলব্ধ।

Copyright (c) 2024 Md Atikul Islam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...

🤝 অবদান রাখুন

আমরা সবার কাছ থেকে অবদান স্বাগত জানাই! যদি আপনি এই প্রকল্পে অবদান রাখতে চান:

  1. Repository ফর্ক করুন
  2. একটি ফিচার ব্রাঞ্চ তৈরি করুন (git checkout -b feature/AmazingFeature)
  3. আপনার পরিবর্তন কমিট করুন (git commit -m 'কিছু দুর্দান্ত ফিচার যোগ করুন')
  4. ব্রাঞ্চে পুশ করুন (git push origin feature/AmazingFeature)
  5. একটি Pull Request খুলুন

📞 যোগাযোগ

লেখক: Md Atikul Islam


🎉 ধন্যবাদ!

এই লাইব্রেরি ব্যবহার করার জন্য ধন্যবাদ। যদি এটি আপনার জন্য সহায়ক হয়, দয়া করে একটি ⭐ স্টার দিয়ে সাহায্য করুন!

আরও ভালো Express routing এর জন্য express-route-framework ব্যবহার করুন! 🚀


শেষ আপডেট: ২০২৬