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

raman-utils

v1.0.1

Published

Reusable utilities for my MERN projects

Readme

Perfect! Here’s a complete README.md for your raman-utils npm package. You can copy this into your project before publishing.

raman-utils

Reusable utilities for MERN projects (MongoDB, Express, JWT).
This package provides common functions and middleware like MongoDB connection, Express server setup, and JWT authentication for fast MERN development.


Installation

npm install raman-utils

Features

MongoDB connection utility (connectDB)

Express server setup (createServer)

JWT authentication middleware (authenticate)

Ready-to-use boilerplate for any MERN project

Usage
1. Importing
const { connectDB, authenticate, createServer } = require("raman-utils");

2. Connect to MongoDB
connectDB(process.env.MONGO_URI); // Connects to your MongoDB

3. Create an Express server
const app = createServer();

app.get("/", (req, res) => {
  res.send("🚀 Server is running!");
});

app.listen(5000, () => console.log("Server running on port 5000"));

4. Protect Routes with JWT
app.get("/dashboard", authenticate, (req, res) => {
  // req.userId is available after authentication
  res.json({ message: "Welcome to the protected route!" });
});


Notes:

authenticate middleware checks:

Authorization header: Bearer <token>

Cookie: token

It attaches req.userId from the decoded JWT.

Functions
connectDB(url)

Connects to MongoDB.

Parameters:

Name	Type	Description
url	string	MongoDB connection string
createServer()

Creates a new Express server with JSON parsing middleware.

Returns: Express app instance.

authenticate(req, res, next)

Express middleware to protect routes.
Checks:

Authorization header (Bearer <token>)

Cookie (token)

Attaches:

req.userId → ID from JWT payload

Usage:

app.get("/protected", authenticate, (req, res) => {
  res.send("You are authenticated!");
});

Environment Variables

Make sure to set these in your project:

MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret

Example Full Server
require("dotenv").config();
const { connectDB, authenticate, createServer } = require("raman-utils");

connectDB(process.env.MONGO_URI);

const app = createServer();

app.get("/public", (req, res) => res.send("Public route"));

app.get("/private", authenticate, (req, res) => {
  res.json({ userId: req.userId, message: "Private route access granted" });
});

app.listen(5000, () => console.log("Server running on 5000"));

License

MIT © Raman Chauhan

Repository

https://github.com/yourusername/raman-utils


---

This README covers:
- Installation
- Usage examples
- Function details
- Environment variables
- Full server example

It’s ready to be **displayed automatically** on npm after you publish.

If you want, I can also **improve it with a table of all functions and parameters** for future functions you might add to `raman-utils`. This makes it look like professional documentation.

Do you want me to do that?