XyPriss is a powerful, TypeScript-first Node.js web framework that enhances your development experience with built-in security, clustering, and performance optimizations. Whether you're building new applications or enhancing existing ones, XyPriss provides the tools you need for scalable, secure web development. Join our community and contribute on GitHub!
XyPriss provides modern security and performance enhancements for Node.js web development
Intuitive routing and middleware system that feels natural to Node.js developers. Works great alongside existing frameworks or as a standalone solution.
12 security middleware modules including CSRF protection, rate limiting, XSS protection, and security headers.
Built-in clustering, multi-tier caching, automatic port detection, and performance optimizations for production workloads.
Complete TypeScript support with full type definitions. Enhanced developer experience with IntelliSense and type safety.
Flexible routing with parameter support, wildcard patterns, router mounting, and route-specific middleware.
Extensible plugin system, specialized modules like ACPES storage, and comprehensive security utilities.
Get started with XyPriss in seconds
# Install XyPriss
npm install xypriss
# With security module
npm install xypriss xypriss-security
# Install XyPriss
yarn add xypriss
# With security module
yarn add xypriss xypriss-security
# Install XyPriss
pnpm add xypriss
# With security module
pnpm add xypriss xypriss-security
See XyPriss in action with these practical examples
Create a simple XyPriss server with built-in security and clustering
import { createServer } from "xypriss";
// Create a XyPriss server
const app = createServer({
cluster: {
enabled: true,
config: {
workers: "auto",
},
},
});
// Use Express-like API
app.get("/", (req, res) => {
res.json({
message: "Hello from XyPriss!",
powered: "Nehonix",
});
});
app.get("/api/users/:id", (req, res) => {
const userId = req.params.id;
res.json({ userId, data: "User data" });
});
// Start the server
app.start();
Flexible routing with parameters, wildcards, and router mounting
import { createServer, Router } from "xypriss";
const app = createServer();
// Parameter routes
app.get("/users/:userId/posts/:postId", (req, res) => {
const { userId, postId } = req.params;
res.json({ userId, postId });
});
// Wildcard routes
app.get("/files/*", (req, res) => {
const filename = req.params["*"];
res.json({ filename });
});
app.get("/api/**", (req, res) => {
const path = req.params["**"];
res.json({ capturedPath: path });
});
// Router system
const userRouter = Router();
userRouter.get("/", (req, res) => {
res.json({ message: "Get all users" });
});
userRouter.post("/", (req, res) => {
res.json({ message: "Create user", data: req.body });
});
// Mount router
app.use("/api/users", userRouter);
console.log("Server started on port:", app.getPort());
Built-in security middleware and XyPriss Security integration
import { createServer } from "xypriss";
import { XyPrissSecurity, fString, fArray } from "xypriss-security";
const server = createServer({
server: { port: 3000 },
security: {
enabled: true,
level: "enhanced",
csrf: true,
helmet: true,
xss: true,
sqlInjection: true,
bruteForce: true,
authentication: {
jwt: {
secret: 'your-secret-key',
expiresIn: '24h'
}
}
}
});
// Secure route with encryption
server.post("/api/secure-data", async (req, res) => {
try {
// Use secure data structures
const secureData = fArray(req.body.sensitiveArray);
const securePassword = fString(req.body.password, {
protectionLevel: "maximum",
enableEncryption: true,
});
// Generate secure token
const token = XyPrissSecurity.generateSecureToken({
length: 32,
entropy: "maximum",
});
res.json({
success: true,
token,
dataLength: secureData.length,
});
} catch (error) {
res.status(500).json({ error: "Security operation failed" });
}
});
server.start(undefined, ()=>{
console.log("Server started on port:", server.getPort());
});
High-performance clustering with caching and auto-scaling
import { createServer } from "xypriss";
const server = createServer({
env: "production",
server: {
port: 8080,
host: "0.0.0.0",
autoPortSwitch: {
enabled: true,
maxAttempts: 5,
portRange: [8080, 8090],
strategy: "increment",
},
},
cache: {
strategy: "hybrid", // Memory + Redis
maxSize: 500 * 1024 * 1024, // 500MB
ttl: 7200, // 2 hours
redis: {
host: "localhost",
port: 6379,
cluster: true,
nodes: [
{ host: "redis-1", port: 6379 },
{ host: "redis-2", port: 6379 },
],
},
},
cluster: {
enabled: true,
workers: "auto", // Auto-detect CPU cores
autoScale: {
enabled: true,
minWorkers: 2,
maxWorkers: 8,
cpuThreshold: 80,
},
},
requestManagement: {
timeout: {
enabled: true,
defaultTimeout: 30000, // 30 seconds
routes: {
"/api/upload": 300000, // 5 minutes for uploads
"/api/quick": 5000, // 5 seconds for quick endpoints
},
},
concurrency: {
maxConcurrentRequests: 1000,
maxPerIP: 50,
},
},
});
// Cached route
server.get("/api/data", async (req, res) => {
const cacheKey = `data:${req.query.id}`;
// Check cache first
const cached = await server.cache.get(cacheKey);
if (cached) {
return res.json({ data: cached, cached: true });
}
// Simulate expensive operation
const data = await fetchExpensiveData(req.query.id);
// Cache the result
await server.cache.set(cacheKey, data, 3600); // 1 hour
res.json({ data, cached: false });
});
server.start();
XyPriss complements Express - use them together or enhance existing Express apps
// Option 1: Enhance existing Express app with XyPriss security
import express from 'express';
import { XyPrissSecurity } from 'xypriss-security';
const app = express();
// Add XyPriss security to your Express app
app.use(XyPrissSecurity.middleware({
csrf: true,
xss: true,
rateLimit: { windowMs: 15 * 60 * 1000, max: 100 }
}));
app.get('/', (req, res) => {
res.json({ message: 'Express + XyPriss Security!' });
});
app.listen(3000);
// Option 2: Run both frameworks side by side
import { createServer } from 'xypriss';
// XyPriss for API services (port 3001)
const apiServer = createServer({
server: { port: 3001 },
security: { enabled: true },
cluster: { enabled: true }
});
apiServer.get('/api/*', (req, res) => {
res.json({ service: 'XyPriss API', secure: true });
});
// Express for web frontend (port 3000)
const webApp = express();
webApp.get('/', (req, res) => {
res.send('Express Frontend');
});
// Start both
apiServer.start();
webApp.listen(3000);
Comprehensive guides and references to help you master XyPriss
Quick start guide to get your first XyPriss server up and running in minutes.
Read Guide →Learn about XyPriss security features and best practices for secure applications.
Security →Configure XyPriss for your specific needs with detailed configuration options.
Configure →