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

@oxog/spark

v1.1.1

Published

Ultra-fast, zero-dependency Node.js web framework with security hardening, memory leak protection, and enhanced error handling

Readme

⚡ Spark

A fast, lightweight, and zero-dependency Node.js web framework built for performance and simplicity.

npm version License: MIT Node.js Version

🚀 Features

  • Zero Dependencies - No external dependencies, pure Node.js
  • High Performance - Built for speed with optimized request handling
  • Middleware Support - Express-like middleware system
  • Advanced Router - Powerful routing with parameter support
  • Session Management - Built-in session handling with auto-save
  • Security First - CORS, CSRF, rate limiting, and security headers
  • TypeScript Support - Full TypeScript definitions included
  • Memory Efficient - Optimized for low memory usage
  • Easy to Use - Simple, intuitive API

📦 Installation

npm install @oxog/spark

🌟 Quick Start

const { Spark } = require('@oxog/spark');

const app = new Spark();

app.get('/', (ctx) => {
  ctx.json({ message: 'Hello World!' });
});

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

📚 Documentation

🎯 Quick Links

📈 Learning Path

🛡️ Production Ready

🔧 Core Components

Application

The main Spark application class that handles server lifecycle, middleware, and routing.

Router

Advanced routing system with support for parameters, middleware, and nested routes.

Context

Request/response context object with helper methods for common operations.

Middleware

Extensible middleware system with built-in middleware for common tasks.

🛠️ Built-in Middleware

  • Body Parser - Parse JSON, form data, and text
  • CORS - Cross-origin resource sharing
  • Session - Session management with auto-save functionality
  • Security - Security headers and protection
  • Rate Limiting - Request rate limiting
  • Compression - Response compression
  • Static Files - Static file serving
  • Logger - Request logging
  • Health Check - Health monitoring endpoints

📊 Performance

Spark is designed for high performance with minimal overhead:

  • ~4000 req/sec on standard hardware
  • <1ms average response time
  • <50MB memory footprint
  • Zero external dependencies

🏗️ Architecture

┌─────────────────┐
│   Application   │
├─────────────────┤
│   Middleware    │
├─────────────────┤
│     Router      │
├─────────────────┤
│    Context      │
├─────────────────┤
│   HTTP Server   │
└─────────────────┘

🔒 Security

Spark includes built-in security features:

  • CORS protection
  • CSRF protection
  • Rate limiting
  • Security headers
  • Input validation
  • XSS protection

🧪 Testing

# Run all tests
npm test

# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:examples

# Run performance benchmarks
npm run benchmark

📈 Examples

Basic API

const { Spark } = require('@oxog/spark');

const app = new Spark();

app.get('/users', (ctx) => {
  ctx.json([
    { id: 1, name: 'John Doe' },
    { id: 2, name: 'Jane Smith' }
  ]);
});

app.get('/users/:id', (ctx) => {
  const { id } = ctx.params;
  ctx.json({ id, name: 'User ' + id });
});

app.listen(3000);

With Middleware

const { Spark } = require('@oxog/spark');

const app = new Spark();

// Global middleware
app.use(require('@oxog/spark/middleware/logger')());
app.use(require('@oxog/spark/middleware/cors')());

// Route-specific middleware
app.get('/protected', 
  require('@oxog/spark/middleware/auth'),
  (ctx) => {
    ctx.json({ message: 'Protected route' });
  }
);

app.listen(3000);

E-commerce API with Sessions

const { Spark, Router } = require('@oxog/spark');

const app = new Spark();
const api = new Router();

// Session middleware with auto-save
app.use(require('@oxog/spark/middleware/session')({
  secret: 'your-secret-key',
  saveUninitialized: true,
  cookie: {
    maxAge: 24 * 60 * 60 * 1000, // 24 hours
    httpOnly: true,
    secure: process.env.NODE_ENV === 'production'
  }
}));

// Authentication
api.post('/auth/login', (ctx) => {
  const { email, password } = ctx.body;
  
  if (authenticate(email, password)) {
    ctx.session.userId = user.id; // Auto-saved immediately
    ctx.json({ success: true });
  } else {
    ctx.status(401).json({ error: 'Invalid credentials' });
  }
});

// Protected routes
api.get('/orders', requireAuth, (ctx) => {
  const orders = getOrdersByUser(ctx.session.userId);
  ctx.json({ orders });
});

app.use('/api', api.routes());
app.listen(3000);

🤝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

📄 License

MIT License - see the LICENSE file for details.

🔗 Links

🌟 Support

If you find Spark useful, please consider giving it a star on GitHub!


Built with ❤️ by the Spark team