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

@angrub/nano-server

v1.0.9

Published

A lightweight, high-performance Node.js framework for building web applications and APIs

Readme

Nano Server 🚀

📝 NOTE: This project is not intended to be a real production-ready framework. It was built for educational purposes, so I strongly recommend using popular, well-tested tools such as: ExpressJs, NestJs or Fastify.

A lightweight, high-performance Node.js framework for building web applications and APIs with TypeScript support.

Features

  • High Performance - Built for speed and efficiency
  • 🛠 TypeScript First - Full TypeScript support out of the box
  • 🔌 Middleware System - Extensible middleware architecture
  • 🛣 Router - Flexible routing with path parameters
  • 🔐 JWT Authentication - Built-in JWT guard middleware
  • 📝 Body Parsing - JSON body parsing middleware
  • 🐇 Messaging - RabbitMQ integration for microservices
  • 📊 Logging - Structured logging with colors
  • 🛡 Error Handling - Comprehensive error handling middleware

Installation

npm install @angrub/nano-server

Quick Start

import { NanoHttpServer, Router } from "@angrub/nano-server";

// Create server with configuration
const app = new NanoHttpServer({
	port: 3000,
	cors: "*", // or specific origins ['http://localhost:3000']
	logs: true, // enable request logging
});

// Create router
const router = new Router();

// Define routes
router.get("/hello", (ctx) => {
	ctx.response.json({ message: "Hello World!" });
});

router.get("/users/:id", (ctx) => {
	const userId = ctx.request.params.id;
	ctx.response.json({ user: { id: userId, name: "John Doe" } });
});

router.post("/users", (ctx) => {
	const userData = ctx.request.body;
	ctx.response.status(201).json({
		message: "User created",
		user: userData,
	});
});

// Add router as middleware
app.add(router);

// Start server
app.listen();

Configuration

const app = new NanoHttpServer({
	port: 3000, // Server port (default: 3000)
	cors: "*", // CORS settings (default: '*')
	logs: true, // Enable request logging (default: false)
});

Middlewares

Built-in Middlewares (Automatically added)

ExceptionHandler - Global error handling

BodyParser - JSON body parsing

RequestLogger - Request logging (if logs: true)

Adding Custom Middlewares

import { INanoMiddleware, NanoCTX, NextFunction } from "@angrub/nano-server";

class CustomMiddleware implements INanoMiddleware {
	async handle(ctx: NanoCTX, next: NextFunction) {
		// Before request
		console.log("Request started:", ctx.request.method, ctx.request.path);

		await next();

		// After request
		console.log("Request completed:", ctx.response.status);
	}
}

app.add(new CustomMiddleware());

Routing

import { Router } from "@angrub/nano-server";

const router = new Router();

// Basic routes
router.get("/users", (ctx) => {
	ctx.response.json({ users: [] });
});

router.post("/users", (ctx) => {
	const userData = ctx.request.body;
	// Process user creation
	ctx.response.status(201).json({ message: "User created" });
});

router.put("/users/:id", (ctx) => {
	const userId = ctx.request.params.id;
	const userData = ctx.request.body;
	// Update user
	ctx.response.json({ message: "User updated" });
});

router.delete("/users/:id", (ctx) => {
	const userId = ctx.request.params.id;
	// Delete user
	ctx.response.json({ message: "User deleted" });
});

// Path parameters
router.get("/users/:id/posts/:postId", (ctx) => {
	const { id, postId } = ctx.request.params;
	ctx.response.json({ userId: id, postId });
});

// Add router to server
app.add(router);

Context Object (NanoCTX)

router.get("/example", (ctx) => {
	// Request information
	console.log(ctx.request.method); // 'GET'
	console.log(ctx.request.path); // '/example'
	console.log(ctx.request.params); // Path parameters
	console.log(ctx.request.body); // Parsed request body
	console.log(ctx.request.getHeader("content-type"));

	// Response methods
	ctx.response.json({ data: "hello" });
	ctx.response.status(201);
	ctx.response.setHeader("X-Custom", "value");

	// Custom payload (for middleware communication)
	ctx.payload.userId = "123";
});

Messaging (RabbitMQ)

import { MessagingService } from "@angrub/nano-server";

const messaging = new MessagingService({
	url: "amqp://localhost:5672",
	queues: [
		{ name: "notifications", durable: true },
		{ name: "events", durable: false },
	],
});

// Start messaging service
await messaging.start();

// Publish messages
await messaging.publish("notifications", {
	type: "user_created",
	data: { userId: 123, email: "[email protected]" },
});

// Subscribe to messages
await messaging.subscribe("events", {
	handle: async (message) => {
		console.log("Received event:", message);
		// Process message
	},
});

Error Handling

import {
	NanoHttpServer,
	Router,
	BadRequestError,
	NotFoundError,
	UnauthorizedError,
} from "@angrub/nano-server";

const app = new NanoHttpServer({ logs: true });
const router = new Router();


router.get("/api/users/:id", (ctx) => {
	const user = getUserById(ctx.request.params.id);

	if (!user) {
		throw new NotFoundError("User not found");
	}

	ctx.response.json({ user });
});

router.post("/api/users", (ctx) => {
	const userData = ctx.request.body;

	if (!userData.email || !userData.name) {
		throw new BadRequestError("Email and name are required");
	}

	const user = createUser(userData);
	ctx.response.status(201).json({ user });
});

app.add(router);
app.listen();

Logging

import { Logger } from "@angrub/nano-server";

const logger = new Logger("App");

logger.info("Application started");
logger.success("Database connected");
logger.warning("Feature is deprecated");
logger.error("Something went wrong", error);

// Contextual logging
const requestLogger = new Logger("HTTP");
requestLogger.info(`Request: ${ctx.request.method} ${ctx.request.path}`);

API Reference

Core Classes

NanoServer - Main server class

Router - Router for defining routes

Request - HTTP request object

Response - HTTP response object

Middlewares

BodyParser - Parse JSON request bodies

JWTGuard - JWT authentication middleware

ExceptionHandler - Global error handling

RequestLogger - Request logging

MessagingMiddleware - RabbitMQ integration

Utilities

Logger - Structured logging

Jwt - JWT token utilities