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

zyroapi

v0.0.1-preview.1

Published

A modern, minimalist, and fast Node.js framework for REST APIs

Readme

✨ ZyroAPI

NPM Version License

A modern, minimalist, and blazingly fast Node.js framework for building REST APIs

ZyroAPI combines Express-like simplicity with modern features and impressive performance. Built with developer experience in mind, it offers clean routing, powerful plugins, and helpful utilities—without the bloat.

🚀 Performance

ZyroAPI delivers production-ready performance that rivals industry leaders:

| Framework | Req/sec | Latency (avg) | Memory | Relative Speed | |-----------|---------|---------------|--------|----------------| | ZyroAPI | 13,594 | 73ms | 104 MB | Baseline | | Fastify | 17,264 | 57ms | 90 MB | +27% faster | | Express | 4,114 | 235ms | 118 MB | -70% slower |

Benchmark Details:

  • System: Intel Xeon @ 2.20GHz (2 cores), 7.76 GB RAM, Node v20.11.1
  • Test: 40s duration, 100 connections, 10 pipelining factor
  • ZyroAPI is 3.3x faster than Express with lower memory usage
  • ZyroAPI achieves 79% of Fastify's speed while maintaining simpler APIs

Benchmarks run on Linux 6.6.111+ using autocannon


✨ Why ZyroAPI?

🎯 Best of Both Worlds

  • Express-like simplicity - Familiar API, minimal learning curve
  • Modern performance - 3.3x faster than Express, 79% of Fastify's speed
  • Developer-friendly - Clean APIs, helpful utilities, great error messages

🚀 Key Features

Core Routing

  • High-performance routing
  • 🛣️ All HTTP methods (GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD)
  • 📍 Route parameters (:id) and wildcards (*)
  • 🔍 Query string parsing built-in

Advanced Features

  • 🧵 Route grouping - Organize routes with app.group()
  • Parallel handlers - Concurrent data fetching with app.parallel()
  • 🔌 Plugin system - Extensible architecture
  • 🎯 Middleware support - Global and route-level
  • 🪝 Hook system - onRequest, preHandler, onResponse, onError

Built-in Plugins

  • 📦 JSON Parser - Automatic request body parsing
  • 🌐 CORS - Secure cross-origin resource sharing
  • 🔒 Secure defaults - Production-ready out of the box

Developer Experience

  • 🔄 Rich response utilities - res.json(), res.send(), res.redirect(), etc.
  • 🧼 Centralized error handling - Consistent error responses
  • 📝 Request decorations - req.params, req.query, req.body, req.ip, etc.
  • 🎨 Beautiful logging - Colorful, informative console output
  • 💪 TypeScript support - Full type definitions included (index.d.ts)

📦 Installation

npm install zyroapi
# or
yarn add zyroapi 

⏱️ Quick Start

// server.js
const { ZyroAPI } = require('zyroapi');

const app = new ZyroAPI();
const PORT = 3000;

// Optional: Enable built-in JSON body parser plugin
app.plug(ZyroAPI.jsonParser);

// Define a simple GET route
app.get('/', (req, res) => {
  res.json({ message: 'Welcome to ZyroAPI!' });
});

// Route with parameters
app.get('/users/:id', (req, res) => {
  const userId = req.params.id;
  res.json({ user_id: userId, message: `Profile for user ${userId}` });
});

// Start the server
app.launch(PORT, () => {
  console.log(`✨ ZyroAPI server running at http://localhost:${PORT}`);
});

Run the server: node server.js

Test it:

  • curl http://localhost:3000/
  • curl http://localhost:3000/users/123

📚 Documentation

For more detailed information, explore the documentation sections:

(See the docs/ directory for detailed guides).


⚙️ Core API Overview

Server Control

  • app.launch(port, callback?): Starts the HTTP server on the specified port.
    app.launch(3000, () => console.log('Server ready!'));

Basic Routing

Define routes using HTTP verb methods: app.get(path, handler) app.post(path, handler) app.put(path, handler) app.patch(path, handler) app.delete(path, handler) app.options(path, handler) app.head(path, handler)

  • path: Route path string (e.g., /users, /posts/:id, /files/*).
  • handler: Function (req, res, next?) to handle the request. Can be async.
// Simple route
app.get('/ping', (req, res) => res.send('pong'));

// Route with parameters
app.get('/items/:itemId', (req, res) => {
  res.json({ item: req.params.itemId, query: req.query });
});

(See Routing Docs for more)

Middleware & Plugins

  • app.attach(middlewareFn): Registers global middleware executed on every request before routing.
    app.attach((req, res, next) => {
      req.requestTime = Date.now();
      console.log(`Request: ${req.method} ${req.url}`);
      next(); // Pass control to the next middleware or handler
    });
  • app.plug(pluginDefinition, options?): Registers a plugin (often using built-in static methods).
    // Enable CORS with specific options
    app.plug(ZyroAPI.cors, { origin: 'https://myfrontend.com' });
    
    // Enable JSON body parsing
    app.plug(ZyroAPI.jsonParser, { limit: '5mb' });

(See Middleware Docs & Plugins Docs)

Error Handling

  • app.error(handlerFn): Registers a custom global error handler.
    app.error((err, req, res) => {
      console.error("ERROR:", err.stack);
      const statusCode = err.statusCode || 500;
      res.status(statusCode).json({
        error: {
           message: err.message || 'Something went wrong!',
           code: err.code
        }
      });
    });

(See Error Handling Docs)

Advanced Routing

  • app.group(prefix, callback): Group routes under a common path prefix.
    app.group('/api/v1', (v1) => {
      v1.get('/users', getAllUsers); // -> /api/v1/users
      v1.post('/users', createUser); // -> /api/v1/users
    });
  • app.parallel(handlerList): Run multiple async handlers concurrently for a single route.
    async function fetchProfile(req) { /* ... */ return { profile: {} }; }
    async function fetchPosts(req) { /* ... */ return { posts: [] }; }
    
    app.get('/user-dashboard', app.parallel([fetchProfile, fetchPosts]));
    // Response will be merged: { profile: {}, posts: [] }

(See Advanced Routing Docs)

Response Utilities

The res object in your handlers is decorated with helpful methods:

  • res.send(data): Sends various data types (string, buffer, object). Auto-detects Content-Type for objects (JSON).
  • res.json(data): Specifically sends JSON response with correct headers.
  • res.status(code): Sets the HTTP status code (chainable).
  • res.type(mime): Sets the Content-Type header (e.g., res.type('html')).
  • res.setHeader(key, value): Sets a response header.
  • res.redirect(url, statusCode?): Sends a redirect response (default 302).
  • res.sendFile(path): Streams a file as the response.
  • res.attachment(filename?): Sets Content-Disposition to trigger download.
  • res.sendStatus(code): Sends only a status code with an empty body.
  • res.end(data?): Low-level method to end the response (less common).

(See Response Docs for details)


⚡ Performance & Optimizations

ZyroAPI is built for speed with carefully optimized internals:

🎯 Performance Optimizations

  • Prototype methods - Zero per-request binding overhead
  • Lazy logger creation - Loggers only created when accessed
  • Fast URL parsing - String operations instead of URL constructor
  • Smart hook execution - Skip empty hooks automatically
  • Optimized buffer handling - Minimal memory allocations
  • Efficient middleware chain - Pre-computed execution paths

📊 Real-World Performance

Test Configuration:
- Duration: 40 seconds
- Connections: 100
- Pipelining: 10x
- System: Intel Xeon @ 2.20GHz, 2 cores, 7.76 GB RAM

Results:
┌──────────┬────────────┬──────────┬─────────┬──────────┐
│ Framework│ Req/sec    │ Latency  │ Memory  │ vs Express│
├──────────┼────────────┼──────────┼─────────┼──────────┤
│ ZyroAPI  │ 13,594     │ 73ms     │ 104 MB  │ +230%    │
│ Fastify  │ 17,264     │ 57ms     │ 90 MB   │ +320%    │
│ Express  │ 4,114      │ 235ms    │ 118 MB  │ Baseline │
└──────────┴────────────┴──────────┴─────────┴──────────┘

Key Takeaways:

  • 3.3x faster than Express with better memory efficiency
  • 79% of Fastify's performance with simpler, more intuitive APIs
  • Production-ready - Handles 13,000+ requests/second
  • Low latency - 73ms average response time under load

Run benchmarks yourself:

npm run benchmark

🤝 Contributing

Contributions are welcome! Whether it's:

  • 🐛 Bug reports
  • 💡 Feature requests
  • 📝 Documentation improvements
  • 🔧 Code contributions

Please feel free to open an issue or submit a pull request on GitHub.


📄 License

MIT License - see LICENSE file for details.


🙏 Acknowledgments

  • Built with find-my-way for high-performance routing
  • Inspired by Express.js simplicity and Fastify performance
  • Thanks to the Node.js community

📬 Support


Made with ❤️ by I._.become_a_devil

⭐ Star us on GitHub if you find ZyroAPI useful!