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

dj-express

v1.0.2

Published

A minimal Express.js implementation for beginners - learn how Express works internally

Readme

DJ Express

A minimal Express.js implementation for beginners to understand how Express works internally.

Perfect for learning: See how routing, middleware, and request handling work under the hood!

Why DJ Express?

  • 🎓 Educational: Learn Express internals in ~100 lines of code
  • 🔍 Transparent: See exactly how app.get(), next(), and res.send() work
  • 🚀 Simple: No complex abstractions, just pure Node.js
  • 📦 Lightweight: Zero dependencies

Installation

npm i dj-express

Quick Start

Option 1: Use as npm package

const { createApp } = require("dj-express");
const app = createApp();

app.get("/", (req, res) => {
  res.json({ message: "Hello from dj-express!" });
});

app.listen(3000);

Option 2: Run the example

git clone <repository-url>
cd mini-express
node example.js

How Express Works (Internally)

1. Routes are just an Array

const routes = [];

app.get = (path, handler) => {
  routes.push({ method: "GET", path, handler });
};

When you call app.get("/users", handler), it simply adds to an array!

2. Middlewares are also an Array

const middlewares = [];

app.use = (middleware) => {
  middlewares.push(middleware);
};

3. The next() Function (Magic!)

let i = 0;

function next() {
  const middleware = middlewares[i++];
  if (middleware) {
    middleware(req, res, next);
  } else {
    handleRoute();
  }
}

next() simply calls the next function in the array!

4. res.send() is just a wrapper

res.send = (data) => {
  if (typeof data === "object") {
    res.setHeader("Content-Type", "application/json");
    res.end(JSON.stringify(data));
  } else {
    res.end(data);
  }
};

5. Body Parsing (Reading POST data)

req.on("data", (chunk) => (body += chunk));
req.on("end", () => {
  req.body = JSON.parse(body);
});

Node.js sends data in chunks, we collect them and parse.

Usage

As npm package

const { createApp } = require("dj-express");

const app = createApp();

// Middleware
app.use((req, res, next) => {
  console.log(req.method, req.url);
  next();
});

// Routes
app.get("/", (req, res) => {
  res.json({ message: "Hello!" });
});

app.get("/users/:id", (req, res) => {
  res.json({ userId: req.params.id });
});

app.post("/data", (req, res) => {
  res.json(req.body);
});

app.listen(3000);

As local module

const { createApp } = require("./index");
// ... rest of the code same as above

Test Commands

# GET request
curl http://localhost:3000/

# Route params
curl http://localhost:3000/users/123

# Query params
curl "http://localhost:3000/search?q=express"

# POST with body
curl -X POST -H "Content-Type: application/json" -d '{"name":"John"}' http://localhost:3000/data

Features

| Feature | How it works | | -------------- | ------------------------------------------------ | | Routing | Routes stored in array, matched by path & method | | Middleware | Array of functions, next() calls the next one | | req.params | Extracted from /users/:id pattern | | req.query | Parsed from ?key=value | | req.body | Parsed from POST request body | | res.send() | Auto-detects JSON vs text | | res.json() | Sends JSON response | | res.status() | Sets status code |

Learn More

License

MIT