celeris-js
v1.0.6
Published
The fastest Celeris backend framework that has done using C++.
Maintainers
Readme
Celeris

A lightweight, modular HTTP server framework for Node.js with middleware support and optional WebSocket integration.
Features
- HTTP routing with support for all main HTTP verbs (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
- Middleware system for request/response manipulation
- JSON body parsing middleware
- Cookie and session management middleware
- CORS support middleware
- WebSocket server integration with room & messaging support
- Simple in-memory response caching layer for fast repeated responses
- Graceful shutdown support
- Error handling and method not allowed support
Installation
npm install celeris-jsBasic Usage
import { Celeris } from "celeris-js";
import { json_parser_middleware } from "./middleware/json_parser.js";
const app = new Celeris("127.0.0.1", 5000);
app.use(json_parser_middleware);
app.get("/", (req, res) => {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ message: "Welcome to Celeris!" }));
});
Middleware
You can create or use built-in middleware to extend functionality:
- json_parser_middleware - Parses JSON body on POST/PUT/PATCH requests
- cookie_parser - Parses cookies into
req.cookies - session_middleware - Session support with cookies
- cors_middleware - Configurable CORS headers
WebSocket Support
Use CelerisWS class to add WebSocket support on the same HTTP server:
import { CelerisWS } from "celeris-js"; // Adjust import path as needed
// Instantiate standalone WebSocket server on port 5000
const wss = new CelerisWS(5000);
// Listen for connection events (already in CelerisWS, but logging again here)
console.log("WebSocket server started on ws://127.0.0.1:5000");
// For testing: after 5 seconds, broadcast a message to all clients
setTimeout(() => {
console.log("Broadcasting message to all clients");
wss.broadcast("Hello all clients! This is a broadcast from the server.");
}, 5000);
Graceful Shutdown
Register hooks to properly close server and clean resources before exit.
License
MIT License
Contributing
Feel free to open issues or submit pull requests!
Author
Mickyas Tesfaye — Mickyas Tesfaye
