
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A lightweight Express‑like framework with multi‑domain support, middleware, dynamic routing, static file serving, and built‑in utilities such as cookie parsing, logging, CORS, sessions, and optional API statistics.
Nutraj is a lightweight, Express‑inspired framework for Node.js that empowers you to build robust APIs and serve static websites effortlessly. With built‑in multi‑domain support, optional API performance tracking, and an extensive middleware suite, Nutraj goes a step further—offering pro features that outshine Express.
Why Nutraj?
Nutraj not only replicates Express's simplicity but also extends it with advanced features like multi-domain hosting, dynamic API statistics, and multiple static folder support. It's designed to be modular, fast, and easy to extend, making it a perfect choice for modern Node.js applications.
Express-like API:
Familiar routing methods (app.get, app.post, etc.) and middleware chaining for rapid development.
Multi-Domain Handling (Pro Feature):
Easily host multiple websites on a single server by delegating requests based on the Host header.
Express does not natively support multi-domain routing.
Dynamic Routing:
Parameterized routes (e.g., /user/:id) with automatic extraction to req.params.
Built-in Middlewares:
req.cookies.req.useragent.Response Enhancements:
Built-in methods like res.send(), res.json(), res.sendFile(), and res.redirect() simplify response handling.
Optional API Statistics (Pro Feature):
Track endpoint performance—hits, total response time, and average response time—with a built‑in /__stats endpoint.
This powerful feature is disabled by default and can be enabled via middleware (app.use(app.stats)).
Extensible & Customizable:
Create custom middleware or error handlers effortlessly. Nutraj’s architecture allows you to plug in additional functionality as your application grows.
Install Nutraj via npm:
npm install nutraj
Create a file named server.js:
const path = require('path');
const Nutraj = require('nutraj');
const app = Nutraj();
// Global middleware
app.use(app.logger);
app.use(app.cookieParser);
app.use(app.useragent);
app.use(app.bodyParser);
app.use(app.session);
// Enable CORS with default settings
app.use(app.cors());
// OPTIONAL: Enable API statistics (disabled by default)
// app.use(app.stats);
// Serve static files from multiple directories
app.use(app.static('public'));
app.use(app.static('assets'));
// Basic route with res.send()
app.get('/', (req, res) => {
res.send('Welcome to Nutraj – A Lightweight Express Alternative with Pro Features!');
});
// Dynamic route using route parameters
app.get('/hello/:name', (req, res) => {
res.send(`Hello, ${req.params.name}! Your user-agent is: ${req.useragent}`);
});
// POST route with full body parsing (JSON, URL-encoded, file uploads)
app.post('/submit', (req, res) => {
res.json({
message: 'Data received successfully!',
body: req.body,
files: req.files || {},
query: req.query
});
});
// Route for redirection
app.get('/redirect', (req, res) => {
res.redirect('/');
});
// Serve a file (ensure "./public/sample.txt" exists)
app.get('/file', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'sample.txt'));
});
// Built-in API statistics endpoint (only active if stats middleware is enabled)
app.get('/__stats', (req, res) => {
res.json({ message: 'Enable API statistics middleware (app.stats) to see route stats.' });
});
// Multi-domain example:
// Create a sub-app for the blog domain.
const blogApp = Nutraj();
blogApp.get('/', (req, res) => {
res.send('Welcome to the Blog!');
});
blogApp.get('/post/:slug', (req, res) => {
res.send(`Displaying blog post: ${req.params.slug}`);
});
// Register the sub-app for the domain "blog.example.com"
app.domain('blog.example.com', blogApp);
// Start the server
app.listen(3000, () => {
console.log('Nutraj server is running on port 3000');
});
Run your server with:
node server.js
Nutraj supports all standard HTTP methods and dynamic routing:
// Define a GET route
app.get('/users', (req, res) => {
res.send('User list');
});
// Define a POST route
app.post('/users', (req, res) => {
res.send('User created');
});
// Define a dynamic route with parameters
app.get('/users/:id', (req, res) => {
// Access route parameter via req.params.id
res.send(`User ID: ${req.params.id}`);
});
Nutraj extends the response object with these helper methods:
Content-Type headers.Nutraj comes with an extensive suite of middleware functions to boost productivity:
Logs each request with detailed information including method, URL, status code, and response time.
app.use(app.logger);
Automatically parses cookies from incoming requests and populates req.cookies.
app.use(app.cookieParser);
Supports parsing JSON, URL-encoded, and multipart/form-data requests.
app.use(app.bodyParser);
Handles simple in-memory sessions. A session cookie (nutraj_session) is set automatically if not present.
app.use(app.session);
Provides easy access to the client’s user-agent via req.useragent.
app.use(app.useragent);
Enables Cross-Origin Resource Sharing with flexible configuration options.
app.use(app.cors());
// Or configure with options:
app.use(app.cors({ origin: 'https://example.com', methods: 'GET,POST' }));
Serve static files from one or more directories. Nutraj processes multiple static middlewares in the order they are added.
app.use(app.static('public'));
app.use(app.static('assets'));
Enable detailed per-route performance tracking by using:
app.use(app.stats);
When activated, Nutraj tracks:
Access statistics at the /__stats endpoint.
Nutraj excels in multi-domain support. Create sub-applications for different domains and delegate requests based on the Host header.
// Create a sub-app for the blog domain
const blogApp = Nutraj();
blogApp.get('/', (req, res) => { res.send('Welcome to the Blog!'); });
blogApp.get('/post/:slug', (req, res) => { res.send(`Post: ${req.params.slug}`); });
// Register the sub-app for "blog.example.com"
app.domain('blog.example.com', blogApp);
Requests with the host blog.example.com are automatically routed to blogApp, giving you native multi-domain support without additional configuration.
app.static() calls if your project contains assets spread across different directories.app.use((err, req, res, next) => {
res.statusCode = 500;
res.send(`Custom Error: ${err.message}`);
});
Nutraj not only replicates Express’s simplicity but also offers additional features:
These pro features make Nutraj an attractive choice for modern, performance-oriented Node.js applications.
MIT
Made with ❤️ by Vaibhav Panday
Contributions, issues, and pull requests are welcome! If you find Nutraj useful, please consider buying me a coffee.
Enjoy building with Nutraj!
FAQs
A lightweight Express‑like framework with multi‑domain support, middleware, dynamic routing, static file serving, and built‑in utilities such as cookie parsing, logging, CORS, sessions, and optional API statistics.
We found that nutraj demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.