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

v1.0.1

Published

Authentication framework for Express.js

Readme

Express Authentication Framework

📖 Overview

এক্সপ্রেস অথেন্টিকেশন ফ্রেমওয়ার্ক - একটি শক্তিশালী এবং ব্যবহার করা সহজ Express.js এবং TypeScript এর জন্য অথেন্টিকেশন সমাধান।

Overview: A robust and easy-to-use authentication solution for Express.js with TypeScript support.


🚀 Features | বৈশিষ্ট্যসমূহ

  • JWT Token-based Authentication - জেডডাব্লিউটি টোকেন ভিত্তিক অথেন্টিকেশন
  • Email & Password Login - ইমেইল এবং পাসওয়ার্ড দিয়ে লগইন
  • Multi-device Support - মাল্টি-ডিভাইস সাপোর্ট
  • Role-based Authorization - ভূমিকা ভিত্তিক অনুমোদন (RBAC)
  • Password Encryption - পাসওয়ার্ড এনক্রিপশন (bcryptjs)
  • Session Management - সেশন ম্যানেজমেন্ট
  • TypeScript Support - সম্পূর্ণ টাইপস্ক্রিপ্ট সাপোর্ট

📦 Installation | ইনস্টলেশন

npm install express-auth-framework

🔧 Project Structure | প্রকল্পের কাঠামো

package/Auth/
├── src/
│   ├── Auth.ts                      # মূল অথেন্টিকেশন ক্লাস (Main Auth class)
│   ├── auth2.ts                     # বৈকল্পিক অথেন্টিকেশন (Alternative implementation)
│   ├── Authentication.ts            # অথেন্টিকেশন মিডলওয়্যার (Auth middleware)
│   ├── Authorize.ts                 # অনুমোদন মিডলওয়্যার (Authorization middleware)
│   ├── index.ts                     # এন্ট্রি পয়েন্ট (Entry point)
│   ├── @types/
│   │   └── index.d.ts              # টাইপ ডেফিনিশন (Type definitions)
│   └── model/
│       ├── token.mode.ts           # টোকেন মডেল (Token model)
│       └── user.mode.ts            # ইউজার মডেল (User model)
├── package.json
├── tsconfig.json
└── README.md

📚 Core Files | মূল ফাইলসমূহ

1. Auth.ts - মূল অথেন্টিকেশন ক্লাস

প্রধান অথেন্টিকেশন লজিক সামলায়। (Main authentication logic handler)

Methods:

  • login() - ইমেইল এবং পাসওয়ার্ড দিয়ে লগইন করুন
  • loginById() - ইউজার আইডি দিয়ে লগইন করুন
  • logout() - একটি ডিভাইস থেকে লগআউট করুন
  • logOutAllDevice() - সব ডিভাইস থেকে লগআউট করুন
  • logoutOtherDevice() - অন্যান্য ডিভাইস থেকে লগআউট করুন

2. Authentication.ts - অথেন্টিকেশন মিডলওয়্যার

এই মিডলওয়্যার জেডডাব্লিউটি টোকেন যাচাই করে এবং ব্যবহারকারীর তথ্য রিকোয়েস্টে সংযুক্ত করে। (Middleware that validates JWT tokens and attaches user data to requests)

3. Authorize.ts - অনুমোদন মিডলওয়্যার

ভূমিকা ভিত্তিক অ্যাক্সেস নিয়ন্ত্রণ। (Role-based access control middleware)


🔑 Key Models | মূল মডেলসমূহ

TokenModel

Properties:
- user_id: সংযুক্ত ব্যবহারকারীর আইডি
- table_name: ব্যবহারকারীর টেবিলের নাম
- token: JWT টোকেন
- deviceName: ডিভাইসের নাম
- last_login_time: শেষ লগইনের সময়

UserModel

Properties:
- id: ব্যবহারকারীর অনন্য আইডি
- email: ইমেইল ঠিকানা
- password: এনক্রিপ্টেড পাসওয়ার্ড
- role: ব্যবহারকারীর ভূমিকা

🎯 Usage Example | ব্যবহারের উদাহরণ

সেটআপ করুন (Setup)

import Authentication from 'express-auth-framework';
import express from 'express';

const app = express();

// Authentication মিডলওয়্যার ব্যবহার করুন
app.use(Authentication);

app.listen(3000, () => {
  console.log('সার্ভার চলছে পোর্ট ৩০০০ এ'); // Server running on port 3000
});

লগইন করুন (Login)

import Auth from './Auth';

// ইমেইল এবং পাসওয়ার্ড দিয়ে লগইন
const result = await Auth.login({
  email: '[email protected]',
  password: 'password123',
  tableName: 'users',
  deviceName: 'মোবাইল' // Mobile
});

console.log(result.token);
console.log(result.user);

অনুমোদন করুন (Authorize)

import Authorize from './Authorize';

// শুধুমাত্র অ্যাডমিন ভূমিকাধারী ব্যবহারকারীদের অ্যাক্সেস দিন
app.get('/admin', Authorize('admin'), (req, res) => {
  res.json({ message: 'আপনি অ্যাডমিন প্যানেলে স্বাগতম' });
});

// একাধিক ভূমিকা অনুমোদন করুন
app.get('/dashboard', Authorize('admin', 'moderator'), (req, res) => {
  res.json({ message: 'ড্যাশবোর্ডে স্বাগতম' });
});

🔐 Environment Variables | পরিবেশ ভেরিয়েবল

আপনার .env ফাইলে সেট করুন:

# JWT এর জন্য সিক্রেট কী
JWT_SECRET=আপনার_দীর্ঘ_এবং_নিরাপদ_কী

# ডাটাবেস কানেকশন
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=আপনার_পাসওয়ার্ড
DB_NAME=আপনার_ডাটাবেস

📋 Type Definitions | টাইপ ডেফিনিশন

AuthRequest

interface AuthRequest extends Request {
  user?: {
    id: string;
    role?: string;
    [key: string]: any;
  };
}

LoginData

interface LoginData {
  email: string;          // ইমেইল
  password: string;       // পাসওয়ার্ড
  tableName?: string;     // ডাটাবেস টেবিল নাম
  deviceName?: string;    // ডিভাইসের নাম
}

AuthUser

interface AuthUser {
  id: number;            // ব্যবহারকারীর আইডি
  role?: string;         // ভূমিকা
  [key: string]: unknown; // অতিরিক্ত ফিল্ড
}

⚙️ Dependencies | নির্ভরশীলতা

{
  "express": "^5.2.1",
  "typescript": "^5.0.0",
  "bcryptjs": "^3.0.3",
  "jsonwebtoken": "^9.0.10",
  "express-mysql-framework": "latest"
}

🛡️ Security Features | নিরাপত্তা বৈশিষ্ট্য

  • Password Hashing - পাসওয়ার্ড bcryptjs দিয়ে হ্যাশ করা হয়
  • JWT Tokens - সুরক্ষিত জেডডাব্লিউটি টোকেন
  • Token Expiration - ২৪ ঘণ্টা পরে টোকেনের মেয়াদ শেষ হয়
  • Multi-device Tracking - প্রতিটি ডিভাইস আলাদাভাবে ট্র্যাক করা হয়
  • Role-based Access - ভূমিকা ভিত্তিক অ্যাক্সেস নিয়ন্ত্রণ

🤝 Contributing | অবদান রাখুন

আমরা আপনার অবদানকে স্বাগত জানাই! অনুগ্রহ করে একটি Pull Request জমা দিন।

We welcome contributions! Please submit a Pull Request.


📄 License | লাইসেন্স

এই প্রকল্পটি MIT লাইসেন্স অনুযায়ী লাইসেন্সপ্রাপ্ত।

This project is licensed under the MIT License.


👤 Author | লেখক

Md Atikul Islam


📞 Support | সহায়তা

যদি আপনার কোনো প্রশ্ন বা সমস্যা থাকে, অনুগ্রহ করে এখানে একটি ইস্যু খুলুন।

If you have any questions or issues, please open an issue here.


শেষ আপডেট: ২০২৬-০৮-১৪ Last Updated: 2026-08-14