/zingjs

A simple lightweight Node.js backend framework with zero dependencies

Primary LanguageJavaScript

ZingJS πŸš€

The Lightweight, Event-Driven Node.js Backend Framework

ZingJS is a fast, file-based, middleware-friendly Node.js framework designed for simplicity, performance, and flexibility. It combines the best features of Express, Fastify, and Hono while keeping things minimal and dependency-free. Yes, you heard it rightβ€”zero dependencies!


✨ Features

βœ… Zero Dependencies – No unnecessary bloat, just pure performance.
βœ… File-Based Routing – Organize routes effortlessly with a folder structure.
βœ… Middleware Support – Use custom middleware, just like Express.
βœ… Event-Driven Architecture – Efficient and modular event-based system.
βœ… Auto API Documentation – Extracts route information directly from comments.
βœ… Static File Serving – Easily serve assets like HTML, CSS, and images.
βœ… Customizable Logging & Rate Limiting – Full control over request logs & throttling.


πŸš€ Installation

npm install zingjs

Since ZingJS has zero dependencies, installation is blazing fast.


πŸ“Œ Quick Start

1️⃣ Create a New Project

mkdir my-zing-app && cd my-zing-app
npm init -y
npm install zingjs

2️⃣ Create an Entry File (index.js)

import ZingJS from "zingjs";

const app = new ZingJS({ enableDocs: true });

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

3️⃣ Define Routes Using File-Based Structure

πŸ“ Folder Structure

/routes
   β”œβ”€β”€ index.js      β†’ GET /
   β”œβ”€β”€ user.js      β†’ GET /user
   β”œβ”€β”€ users/[id].js β†’ GET /users/:id

πŸ“„ routes/users/[id].js

/**
 * @route   GET /users/:id
 * @desc    Fetch user details
 * @params  id - User ID
 * @return  { userId, name }
 **/
export default {
  GET: async (req) => {
    return { userId: req.params.id, name: "John Doe" };
  }
};

4️⃣ Start the Server

node index.js

Your API is now live at http://localhost:3000!


πŸ“„ API Documentation

ZingJS automatically generates API documentation from inline comments.

View API Docs at: http://localhost:3000/docs

Example:

{
  "/users/:id": {
    "get": {
      "description": "Fetch user details",
      "params": ["id - User ID"],
      "return": "{ userId, name }",
      "responses": {
        "200": { "description": "Successful response" }
      }
    }
  }
}

πŸ”₯ Advanced Features

βœ” Middleware Support

app.use((req, res, next) => {
  console.log(`Incoming request: ${req.method} ${req.url}`);
  next();
});

βœ” Static File Serving

const app = new ZingJS({ serveStatic: true });

Place your static files inside public/, and access them at /.

βœ” Event System

app.on("userCreated", (data) => {
  console.log("New user added:", data);
});

πŸ”— Contributing

We welcome contributions! Feel free to fork the repository and submit a pull request.


πŸ“œ License

ZingJS is released under the MIT License.


⭐ Why ZingJS?

πŸš€ Fast & Lightweight – Zero dependencies ensure minimal footprint.
πŸ“ Easy to Use – Simple API design with file-based routing.
πŸ”§ Flexible & Extensible – Customize everything as per your needs.
🎯 Designed for Performance – Event-driven, optimized for speed.

Start building amazing APIs with ZingJS today! πŸš€