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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rnatsuki/express-lite

v1.1.1

Published

A lightweight Express-like HTTP framework for Node.js

Readme

ExpressLite

A lightweight, TypeScript-based framework inspired by Express.js for building web applications and APIs with a familiar API.

Note: As of version 1.1.0, this package uses ES modules (not CommonJS).

Features

  • Express-like API with modern TypeScript support
  • Middleware pipeline for request/response processing
  • Flexible routing with support for HTTP methods and parameters
  • Modular architecture using Router instances
  • Built-in middleware for common tasks (body parsing, CORS, logging)

Installation

# Using pnpm (recommended)
pnpm add @rnatsuki/express-lite

# Using npm
npm install @rnatsuki/express-lite

# Using yarn
yarn add @rnatsuki/express-lite

Quick Start

import express from '@rnatsuki/express-lite';
const app = express();

// Use middleware
app.use(express.json());
app.use(express.logger());

// Define routes
app.get('/', (req, res) => {
  res.send('Hello, ExpressLite!');
});

app.post('/api/users', (req, res) => {
  const user = req.body;
  // Process user data
  res.json({ message: 'User created', user });
});

// Start the server
app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Core Components

Application

The main application instance that handles HTTP requests, middleware, and routing.

// Create an application
const app = express();

// Add middleware
app.use(someMiddleware);

// Define routes
app.get('/path', handler);
app.post('/path', handler);
app.put('/path', handler);
app.delete('/path', handler);

// Start the server
app.listen(port, callback);

Router

Used for creating modular route handlers that can be mounted to the main application.

const router = express.Router();

// Add router-specific middleware
router.use(authMiddleware);

// Define routes on the router
router.get('/users', getAllUsers);
router.post('/users', createUser);
router.get('/users/:id', getUserById);

// Mount the router on the application
app.mount('/api', router);

Middleware

Functions that have access to the request and response objects and can:

  • Execute code
  • Modify the request and response objects
  • End the request-response cycle
  • Call the next middleware in the stack
// Custom middleware example
const myMiddleware = (req, res, next) => {
  // Do something with req or res
  console.log(`Request to ${req.path}`);
  
  // Continue to next middleware
  next();
};

app.use(myMiddleware);

Built-in Middleware

  • express.json() - Parses JSON request bodies
  • express.urlencoded() - Parses URL-encoded request bodies
  • express.cors() - Enables CORS for all routes
  • express.logger() - Logs request information
  • express.static() - Serves static files from a directory (added in v1.1.0)

Version History

v1.1.0

  • Added static file middleware with support for serving static files from directories
  • Migrated to ES modules
  • Fixed type definitions
  • Added more examples

v1.0.0

  • Initial release with core functionality
  • Express-like API with middleware support
  • Routing capabilities

Common Examples

Serving Static Files

ExpressLite includes a static file middleware that serves files from a specified directory. This was added in version 1.1.0.

import express from '@rnatsuki/express-lite';
import path from 'path';

const app = express();

// Basic usage - serve files from the 'public' directory
app.use(express.static('public'));

// Advanced usage with options
app.use(express.static(new URL('./public', import.meta.url).pathname, {
  index: 'index.html',     // Default index file for directory requests
  dotfiles: 'ignore',      // How to handle dotfiles: 'allow', 'deny', or 'ignore'
  etag: true,              // Enable ETag header generation
  maxAge: 86400,          // Cache control max-age in seconds (1 day)
}));

app.listen(3000, () => {
  console.log('Server running at http://localhost:3000');
});

Content Type Detection

The static middleware automatically detects the appropriate content type based on file extension:

// For example:
// http://localhost:3000/styles.css → Content-Type: text/css
// http://localhost:3000/image.png → Content-Type: image/png
// http://localhost:3000/data.json → Content-Type: application/json

Route Parameters

app.get('/users/:id', (req, res) => {
  const userId = req.params.id;
  res.send(`User ID: ${userId}`);
});

API with JSON Responses

import express from '@rnatsuki/express-lite';

const app = express();

app.get('/api/products', (req, res) => {
  const products = [/* product data */];
  res.json(products);
});

Error Handling

// Error handling middleware
import express from '@rnatsuki/express-lite';

const app = express();

app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});

Limitations Compared to Express.js

  • Limited middleware ecosystem compared to Express.js
  • Fewer features for advanced use cases like template engines
  • Less mature and tested in production environments
  • May not support all advanced routing patterns
  • Limited documentation and community support
  • No built-in view system
  • Static file serving is more basic than Express.js

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT