JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q30515F
  • License MIT

🎓 LEARNING PROJECT: My first attempt at building a Node.js web framework with Express-compatible API. Educational purposes only - NOT recommended for production use. Features TypeScript, zero dependencies, and plugin architecture.

Package Exports

  • nextrush
  • nextrush/package.json

Readme

⚡ NextRush - Learning Project

🎓 Educational Web Framework Project - My First NPM Package Journey

⚠️ IMPORTANT: This is a LEARNING PROJECT and my first experience building a web framework. > NOT recommended for production use. Built for educational purposes only.

📚 Learning Project Notice

This project represents my first attempt at building a Node.js web framework and publishing an NPM package. It was created as a learning experience to understand:

  • Framework architecture and design patterns
  • TypeScript development and type safety
  • NPM package development and publishing
  • Plugin-based architectures
  • Performance optimization techniques
  • Web server fundamentals

🚨 For Production Use: Please consider📚 Educatio📚 Educational Resources:**

🚀 Next Chapter: NextRush v2.0 - Applying lessons learned to build it right from the start.


Philosophy

"The best way to learn is to build something ambitious, make mistakes, and share the journey with others." - This Project's Philosophyd frameworks like Express.js, Fastify, Koa, or Hapi instead.

📖 Learning Documentation: See LESSONS-LEARNED.md for detailed insights from this project.


Learning Project First NPM Package TypeScript License: MIT Educational

import { createApp } from 'nextrush';

const app = createApp();

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

app.listen(3000);
// 🚀 Educational Express.js-compatible API with built-in features

🎓 About This Learning Project

NextRush v1.0 represents my first journey into framework development and NPM package publishing. This project was built as an educational experience to learn:

📚 What I Learned:

  • Framework Architecture: Understanding how web frameworks work internally
  • Plugin Systems: Designing extensible, modular architectures
  • TypeScript Development: Advanced type systems and API design
  • Performance Testing: Benchmarking, profiling, and optimization techniques
  • NPM Publishing: Package development, versioning, and distribution
  • Open Source Development: Documentation, community engagement, and maintenance

🏗️ Technical Achievements:

  • Zero Dependencies - Built everything from Node.js primitives
  • Express.js Compatibility - Drop-in replacement API design
  • Plugin Architecture - Modular, extensible system
  • TypeScript-First - Full type safety and IntelliSense support
  • Comprehensive Benchmarking - Professional performance testing suite
  • Complete Documentation - Extensive guides and API references

📊 Learning Outcomes:

  • Architecture Planning is more important than coding speed
  • Simple solutions often outperform complex optimizations
  • Testing should come before features, not after
  • Plugin systems must be designed from day 1, not retrofitted
  • Performance comes from good architecture, not micro-optimizations

🚀 Next Steps:

This project has taught me invaluable lessons about framework development. The knowledge gained will be applied to NextRush v2.0 - a complete rewrite with proper architecture planning and incremental development.

📖 Detailed Learning Journey: See LESSONS-LEARNED.md for comprehensive insights.


⚠️ Production Use Disclaimer

While NextRush includes many enterprise-grade features and achieves decent performance (1,400 RPS), it was built as a learning project and my first attempt at framework development.

For Production Applications, please use proven frameworks:

  • Express.js - The standard Node.js framework
  • Fastify - High-performance alternative
  • Koa - Minimalist, modern framework
  • Hapi - Enterprise-focused framework

🔥 What Makes NextRush Special

  • 🛡️ Built-in Security - Validation, sanitization, XSS protection out of the box
  • 📦 Zero Dependencies - No bloat, just pure performance
  • 🚀 Express Compatible - Drop-in replacement for existing Express.js apps
  • 🎯 TypeScript First - Full type safety with intelligent autocompletion
  • Performance Focused - Optimized for production workloads
  • 🔌 Everything Built-in - No need for dozens of middleware packages

🔥 Key Features

  • 🛡️ Built-in security (validation, sanitization, XSS protection)
  • 📁 Professional static files with compression & caching
  • 🌐 Built-in WebSocket support with room management
  • 📊 Ultimate body parser with file uploads
  • 🎨 Multi-syntax templates (Mustache, Handlebars, EJS)
  • 🍪 Enhanced request/response objects
  • 🔧 Zero dependencies for core features
  • 📝 TypeScript-first with automatic type inference
  • 🔄 Express.js compatible - drop-in replacement
  • Performance optimized with smart caching
  • 🛡️ Built-in rate limiting and CORS protection
  • 🔐 JWT & session authentication with RBAC
  • 📊 Metrics & monitoring with health checks
  • 📚 Auto API documentation with Swagger UI

🏗️ NextRush vs The Competition

Why choose NextRush over Express.js, Fastify, or Koa?

Feature NextRush Express.js Fastify Koa Hapi
Zero Dependencies
TypeScript First ⚠️ ⚠️ ⚠️
Built-in Body Parser ❌ Need middleware ❌ Need middleware
Built-in File Uploads ❌ Need multer ❌ Need plugins ❌ Need middleware ❌ Need plugins
Built-in WebSocket ❌ Need socket.io ❌ Need plugins ❌ Need packages ❌ Need packages
Built-in Templates ❌ Need engines ❌ Need plugins ❌ Need packages ⚠️
Built-in Validation ❌ Need express-validator ❌ Need plugins ❌ Need packages
Built-in Security ❌ Need helmet + others ❌ Need plugins ❌ Need packages
Built-in Rate Limiting ❌ Need express-rate-limit ❌ Need plugins ❌ Need packages
Built-in Auth ❌ Need passport + others ❌ Need plugins ❌ Need packages ⚠️
API Docs Generation ❌ Need swagger packages ❌ Need plugins ❌ Need packages ❌ Need packages
Express Compatible
Performance Ranking 5th 2nd 3rd 1st 4th

Real-World Benchmark Results

Latest benchmarks run on Node.js v24.4.1, Intel i5-8300H, 8 cores, 15GB RAM

🏆 Framework Performance Comparison

Rank Framework Version Avg RPS Avg Latency Memory Usage Success Rate
🥇 Koa 3.0.0 3,600 1.54ms 70MB 100%
🥈 Express 5.1.0 2,130 2.34ms 122MB 100%
🥉 Fastify 5.4.0 1,700 2.35ms 70MB 100%
4️⃣ Hapi 21.4.0 1,560 2.59ms 72MB 100%
5️⃣ NextRush 1.3.0 1,400 2.71ms 75MB 100%

🎯 Test Scenarios Performance

Simple Route (Hello World)

  • NextRush: 556 RPS @ 1.8ms latency
  • Express: 3,220 RPS @ 0.31ms latency
  • Fastify: 611 RPS @ 1.63ms latency

JSON API Response

  • NextRush: 567 RPS @ 1.76ms latency
  • Express: 3,360 RPS @ 0.30ms latency
  • Koa: 3,740 RPS @ 0.27ms latency

POST Body Parsing

  • NextRush: 583 RPS @ 1.71ms latency
  • Express: 527 RPS @ 1.89ms latency
  • Koa: 2,830 RPS @ 0.35ms latency

🧠 Memory & Resource Analysis

Memory Efficiency Comparison:

  • NextRush: 75MB - Moderate usage with full feature set
  • Express: 122MB - Higher usage due to multiple dependencies
  • Fastify: 70MB - Lean but requires plugins for features
  • Koa: 70MB - Minimal base, memory grows with packages
  • Hapi: 72MB - Enterprise features with good efficiency

Key Insights:

  • NextRush has zero memory leaks detected across all test scenarios
  • Plugin Architecture allows selective feature loading (Performance mode uses only 4 essential plugins)
  • Memory Monitoring built-in with metrics endpoint for production monitoring
  • GC Optimization - Smart buffer pooling reduces garbage collection pressure

The Bottom Line

  • Koa: Fastest overall, but minimal features requiring many packages
  • Express.js: Great performance, but requires 15+ packages for production features
  • Fastify: Good performance with more features, but complex plugin ecosystem
  • Hapi: Enterprise features built-in, moderate performance
  • NextRush: Everything built-in with zero dependencies - trading some raw speed for convenience and completeness

NextRush Philosophy: We prioritize developer productivity and zero-dependency deployment over raw performance. While we're working on performance optimizations, our 1,400 RPS is sufficient for most applications while providing a complete, production-ready framework out of the box.

🔬 Benchmark Methodology

Our comprehensive benchmarking uses professional tools and real-world scenarios:

Tools Used:

  • Autocannon - HTTP load testing with connection pooling
  • Artillery - Stress testing with complex scenarios
  • Clinic.js - Performance profiling and bottleneck analysis
  • K6 - Load testing with detailed metrics
  • Custom Memory Monitoring - Real-time resource tracking

Test Scenarios:

  • Simple routes, JSON responses, middleware chains
  • Parameter parsing, error handling, large payloads
  • POST body parsing, nested routes, static file serving
  • Query parameters, headers, WebSocket connections

Metrics Collected:

  • Requests per second (RPS), latency percentiles (P50, P95, P99)
  • Memory usage (heap, RSS, external), CPU utilization
  • Memory leak detection, garbage collection pressure
  • Network throughput, connection management

🚀 Quick Start

Performance Note: NextRush includes a Performance Mode for production deployments that loads only essential plugins for maximum speed. See Performance Optimization Guide for details.

Installation

# NPM
npm install nextrush

# Yarn
yarn add nextrush

# PNPM
pnpm add nextrush

Your First NextRush App

import { createApp, PluginMode } from 'nextrush';

// For development - full features
const app = createApp();

// For production - performance optimized (1,400+ RPS)
// const app = createApp({
//   pluginMode: PluginMode.PERFORMANCE,
//   enableEvents: false,
//   enableWebSocket: false
// });

// Express.js style - works unchanged!
app.get('/api/users/:id', (req, res) => {
  const { id } = req.params;
  res.json({
    user: id,
    ip: req.ip(), // Enhanced request
    secure: req.secure(), // Built-in utilities
  });
});

// Enhanced features work out of the box
app.post('/api/upload', (req, res) => {
  const file = req.file('document'); // Auto file parsing
  const data = req.body; // Auto JSON parsing
  const validation = req.validate({
    // Built-in validation
    title: { required: true, type: 'string' },
  });

  if (!validation.isValid) {
    return res.status(400).json({ errors: validation.errors });
  }

  res.json({
    uploaded: file?.filename,
    data: validation.sanitized,
  });
});

app.listen(3000, () => {
  console.log('🚀 NextRush server running on http://localhost:3000');
});

🔄 Migrating from Express.js?

Most Express.js code works unchanged! Just replace the import:

- const express = require('express');
- const app = express();
+ import { createApp } from 'nextrush';
+ const app = createApp();
+ const app = new Application();

// Everything else stays exactly the same!
app.get('/', (req, res) => {
  res.json({ message: 'Works perfectly!' });
});

📖 Complete Migration Guide →

🔥 Built-in Superpowers

🛡️ Security & Validation - Zero Configuration

app.post('/api/secure', (req, res) => {
  // Input validation with detailed error messages
  const validation = req.validate({
    email: { required: true, type: 'email' },
    age: { type: 'number', min: 18, max: 120 },
    name: { required: true, minLength: 2 },
  });

  if (!validation.isValid) {
    return res.status(400).json({ errors: validation.errors });
  }

  // Data sanitization (XSS, HTML stripping, etc.)
  const clean = req.sanitize(req.body.bio, {
    removeHtml: true,
    escape: true,
    trim: true,
  });

  res.json({
    message: 'Data is clean and validated!',
    sanitized: clean,
  });
});

📁 Professional Static Files - Production Ready

// Enterprise-grade static file serving
app.static('/assets', './public', {
  compression: true, // Auto gzip/brotli compression
  caching: true, // Smart ETags and cache headers
  spa: true, // Single Page App support
  maxAge: '1y', // Cache control headers
  headers: {
    // Custom headers
    'X-Powered-By': 'NextRush',
  },
});

// Multiple static directories
app.static('/uploads', './uploads', {
  maxAge: '30d',
  index: false,
});

🌐 WebSocket - Real-time Made Easy

// Zero-dependency WebSocket with room management
app.ws('/chat/:room', (socket, req) => {
  const room = req.params.room;
  const userId = req.query.userId;

  // Join room automatically
  socket.join(room);

  // Broadcast to room
  socket.broadcast.to(room).send(`User ${userId} joined ${room}`);

  // Handle messages
  socket.on('message', (data) => {
    socket.broadcast.to(room).send(data);
  });

  // Handle disconnect
  socket.on('close', () => {
    socket.broadcast.to(room).send(`User ${userId} left`);
  });
});

🎨 Template Engine - Super Simple Setup

import { createApp, quickTemplate } from 'nextrush';

const app = createApp();

// ONE LINE SETUP! 🎉
app.setTemplateEngine(quickTemplate());

// Render templates with built-in helpers
app.get('/welcome/:name', (req, res) => {
  res.render('Hello {{name}}! Price: {{currency 29.99}}', {
    name: req.params.name,
  });
});

// Custom helpers made easy
app.setTemplateEngine(
  quickTemplate({
    badge: (type: string, text: string) => `[${type.toUpperCase()}] ${text}`,
    timeAgo: (minutes: number) => `${minutes} minutes ago`,
  })
);

app.get('/status', (req, res) => {
  res.render('{{badge "success" "All systems operational"}} {{timeAgo 5}}', {});
});

📊 Body Parser - Handle Everything

// Automatic parsing of JSON, forms, files
app.post('/api/data', (req, res) => {
  // JSON and form data - automatically parsed
  const { title, description } = req.body;

  // Single file upload
  const avatar = req.file('avatar');

  // Multiple files
  const documents = req.files('documents');

  // File validation built-in
  if (avatar && !avatar.isImage()) {
    return res.status(400).json({ error: 'Avatar must be an image' });
  }

  res.json({
    data: { title, description },
    avatar: avatar?.filename,
    documents: documents?.map((f) => f.filename),
  });
});

🛡️ Rate Limiting & CORS - Enterprise Security

// Built-in rate limiting with multiple strategies
app.rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100, // 100 requests per window
  message: 'Too many requests, please slow down',
  skipSuccessfulRequests: true,
});

// CORS with security presets
app.cors('production'); // Secure defaults for production

// Or detailed configuration
app.cors({
  origin: ['https://mydomain.com', 'https://app.mydomain.com'],
  credentials: true,
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  allowedHeaders: ['Content-Type', 'Authorization'],
});

🔐 Authentication & Authorization - Built-in

// JWT authentication
app.use(
  '/api',
  app.auth('jwt', {
    secret: process.env.JWT_SECRET,
    algorithms: ['HS256'],
  })
);

// Role-based access control
app.get('/admin/*', app.requireRole('admin'), (req, res) => {
  res.json({ message: 'Admin area', user: req.user });
});

// Session-based authentication
app.use(
  '/dashboard',
  app.auth('session', {
    secret: process.env.SESSION_SECRET,
    store: 'redis',
    cookie: { secure: true, httpOnly: true },
  })
);

📊 Metrics & Monitoring - Production Insights

// Enable comprehensive metrics
app.enableMetrics({
  prometheus: true, // Prometheus format metrics
  healthCheck: true, // Health check endpoint
  performance: true, // Performance monitoring
});

// Custom metrics
app.use((req, res, next) => {
  app.metrics.increment('requests.total', {
    method: req.method,
    path: req.route?.path || 'unknown',
  });
  next();
});

// Access endpoints:
// GET /metrics      - Prometheus format
// GET /health       - Health check
// GET /metrics/json - JSON format

📚 API Documentation - Auto-Generated

// Enable Swagger documentation
app.enableApiDocs({
  title: 'My Amazing API',
  version: '1.0.0',
  description: 'Built with NextRush',
  servers: [{ url: 'https://api.mydomain.com' }],
});

// Document endpoints automatically
app
  .get('/users/:id', (req, res) => {
    // Documentation inferred from route and validation
    res.json({ user: req.params.id });
  })
  .doc({
    summary: 'Get user by ID',
    tags: ['Users'],
    parameters: [
      { name: 'id', in: 'path', required: true, schema: { type: 'string' } },
    ],
    responses: {
      200: { description: 'User found' },
      404: { description: 'User not found' },
    },
  });

// Access documentation:
// GET /swagger      - Interactive Swagger UI
// GET /api-docs.json - OpenAPI specification

📚 Complete Documentation

🚀 Getting Started

🏗️ Core Framework

📋 Core Features

🛡️ Security & Performance

🚀 Advanced Features

🏆 Production Ready Features

NextRush is built for enterprise-grade applications with:

  • 🔒 Security-First Design - Secure defaults, input validation, XSS protection
  • High Performance - Optimized for production workloads, smart caching
  • 🛡️ Comprehensive Error Handling - Detailed logging and error tracking
  • 📊 Memory Efficient - Smart memory management and garbage collection
  • 🔧 Zero-Config Deployment - Works out of the box in any environment
  • 📈 Horizontally Scalable - Built for microservices and cloud deployment

💻 TypeScript Excellence

// Full type safety with intelligent autocompletion
app.get('/users/:id', (req, res) => {
  // req.params.id is automatically typed as string
  const userId: string = req.params.id;

  // req.body gets proper typing with generics
  const data: UserCreateData = req.body;

  // Response methods are fully typed
  res.json({ user: userId, timestamp: Date.now() });
  //  ^^^^ TypeScript knows this returns JSON
});

// Generic support for request/response typing
interface CreateUserRequest {
  name: string;
  email: string;
  age: number;
}

app.post<CreateUserRequest>('/users', (req, res) => {
  // req.body is now properly typed as CreateUserRequest
  const { name, email, age } = req.body;
  //      ^^^^ Full autocompletion and type checking
});

🌟 Community & Support

📞 Get Help

🤝 Contributing

We welcome contributions! Check out:

📈 Roadmap

  • 🔜 GraphQL Integration - Built-in GraphQL support
  • 🔜 Database ORM Adapters - Prisma, TypeORM integration
  • 🔜 Microservice Utilities - Service discovery, circuit breakers
  • 🔜 Advanced Monitoring - Distributed tracing, APM integration
  • 🔜 Serverless Deployment - AWS Lambda, Vercel support

📚 Learning Project Documentation

This repository contains comprehensive documentation about my framework development journey:

📖 Key Documents

🎯 Educational Value

This project serves as a complete case study for:

  • Framework development challenges and solutions
  • Architecture decision consequences
  • Performance optimization techniques
  • NPM package development process
  • First-time open source project management

Show Your Support for This Learning Journey

If this learning project helps other developers understand framework development:

  • Star this repository to help others find it
  • 🎓 Share your own learning projects with #LearningInPublic
  • 📝 Document your development journey for others to learn from
  • 🗣️ Encourage other developers to build ambitious learning projects
  • 💬 Share feedback about what you learned from this codebase

🎓 For Aspiring Framework Developers

If you're inspired to build your own framework:

  1. Read LESSONS-LEARNED.md first
  2. Plan your architecture before coding
  3. Start simple and build incrementally
  4. Document your journey for others
  5. Don't be afraid to make mistakes - they're the best teachers!

Performance & Optimization Roadmap

📈 Current Status (v1.3.0)

NextRush currently ranks 5th out of 5 in raw performance benchmarks, but 1st in developer experience and built-in features:

  • Current Performance: 1,400 RPS avg (sufficient for most applications)
  • Memory Usage: 75MB (competitive with other frameworks)
  • Zero Dependencies: Complete framework without external packages
  • Express Compatibility: Drop-in replacement for existing Express apps

🎯 Performance Improvement Plan

We're actively working on performance optimizations while maintaining our zero-dependency philosophy:

  1. Route Matching Optimization - Implementing trie-based routing for O(1) lookups
  2. Buffer Pooling - Reducing GC pressure with smart buffer management
  3. Streaming Support - Zero-copy transfers for large payloads
  4. Plugin Mode Optimization - Performance mode with minimal plugins (already implemented)
  5. HTTP Keep-Alive - Reducing TCP handshake overhead

🔍 Benchmark Details

Our benchmarks test real-world scenarios across multiple dimensions:

  • 11 Different Test Cases: Simple routes, JSON responses, middleware chains, parameter parsing, error handling, large payloads, POST echo, nested routes, static files, query parameters, headers
  • Memory Monitoring: Peak usage, leaks detection, GC pressure analysis
  • Professional Tools: Autocannon, Artillery, Clinic.js for comprehensive analysis
  • Cross-Platform: Testing on multiple Node.js versions and operating systems

View full benchmark reports: Benchmark Results | Professional Benchmarks

📄 License

MIT License - see LICENSE file for details.


🎓 Built with ❤️ for Learning

This project represents my journey from beginner to framework developer. It's proof that anyone can build complex software with dedication and learning.

📚 Educational Resources:

🚀 Next Chapter: NextRush v2.0 - Applying lessons learned to build it right from the start.


Learning Philosophy

"The best way to learn is to build something ambitious, make mistakes, and share the journey with others." - This Project's Core Belief