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

praveen-microservice

v1.0.0

Published

Microservice-ready RBAC middleware using Node.js, JWT authentication, and service-to-service communication. Supports role and permission-based access control without using populate.

Readme

RBAC Microservice System (Node.js)

A scalable Role-Based Access Control (RBAC) system built using microservice architecture with Node.js, Express, MongoDB, and JWT authentication. Designed for reusable middleware and production-ready backend systems.


Features

  • JWT authentication
  • User (Auth) service
  • Role and Permission (RBAC) service
  • Service-to-service communication using Axios
  • No cross-service populate (microservice-safe)
  • Clean and scalable architecture
  • Reusable middleware (npm-ready)

Architecture Overview

Auth Service (User - 9991) | | HTTP (Axios) v RBAC Service (Role & Permission - 9999)


Services

Auth Service (User)

  • Handles user login and authentication
  • Generates JWT tokens
  • Stores user data with role reference

RBAC Service

  • Manages roles
  • Manages permissions
  • Handles access control logic

Tech Stack

  • Node.js
  • Express.js
  • MongoDB with Mongoose
  • JSON Web Token (JWT)
  • Axios

Environment Variables

Auth Service (.env)

PORT=9991 MONGO_URI=your_mongo_uri JWT_SECRET=your_secret_key ROLE_SERVICE_URL=http://localhost:9999/microservice/role

RBAC Service (.env)

PORT=9999 MONGO_URI=your_mongo_uri JWT_SECRET=your_secret_key USER_SERVICE_URL=http://localhost:9991/microservice/user


Authentication Flow

  1. User logs in via Auth Service
  2. JWT token is generated
  3. Client sends token in headers: Authorization: Bearer
  4. Middleware verifies token
  5. Role and permissions are resolved via API or JWT

Middleware Usage

import { protect } from "./middleware/protect.js";

app.get("/secure-route", protect, (req, res) => {
  res.json({ message: "Access granted", user: req.user });
});

Microservice Communication Example

const response = await axios.get(
  `${process.env.ROLE_SERVICE_URL}/${user.role}`
);

const role = response.data.role;

Best Practices

  • Do not use populate across microservices
  • Use API-based communication
  • Keep services independent
  • Use environment variables for configuration
  • Maintain separation of concerns

Future Enhancements

  • API Gateway
  • Redis caching
  • Store permissions in JWT
  • Rate limiting and security improvements
  • TypeScript support

NPM Usage (Reusable Middleware)

npm install your-package-name

import { protect } from "your-package-name";

app.get("/secure", protect, (req, res) => {
  res.send("Protected route");
});

Author

Praveen Digitalks


License

MIT