Package Exports
- xypriss
- xypriss/package.json
Readme
XyPriss (Beta)
A powerful Node.js web framework with built-in security, clustering, and performance optimizations for modern web applications.
Overview
XyPriss is a powerful, TypeScript-first, open-source Node.js web framework that enhances your development experience with built-in security middleware, 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.
Key Features
- Familiar API: Intuitive syntax for defining routes and middleware
- Built-in Security: 12+ security middleware modules (CSRF, XSS, rate limiting)
- File Upload Support: Seamless multipart/form-data handling with automatic error handling
- XJson API: Advanced JSON serialization handling BigInt, circular references, and large data
- Multi-Server Mode: Run multiple server instances with different configurations
- Flexible Routing: Parameters, wildcards, and modular routers
- TypeScript Support: Full type definitions for better DX
- Performance: Advanced clustering, caching, and optimizations
Note: XyPriss is the successor to FortifyJS, which will be deprecated. Migration Guide
Installation
npm install xypriss
# or
yarn add xyprissFor additional security features:
npm install xypriss-securityQuick Start
Recommended: Use XyPriss CLI
# Install the CLI globally
npm install -g xypriss-cli
# Create a new project
xypcli init
# Start development
cd your-project-name
npm run devThe CLI automatically generates a complete project structure with authentication, file upload support, and multi-server configuration (all optional).
Manual Setup
import { createServer } from "xypriss";
const server = createServer({
server: { port: 3000 },
security: { enabled: true },
performance: { clustering: true },
});
server.get("/", (req, res) => {
res.json({ message: "Hello from XyPriss!", powered: "Nehonix" });
});
// XJson example for handling BigInt and large data
server.get("/api/data", (req, res) => {
const data = {
id: 123n, // BigInt value
timestamp: new Date(),
items: Array.from({ length: 1000 }, (_, i) => ({
id: i,
value: BigInt(i * 1000),
})),
};
res.xJson(data); // Advanced JSON handling
});
server.start(() => {
console.log(`Server running at http://localhost:${server.getPort()}`);
});Documentation
Core Guides
- Routing - Routes, parameters, wildcards, and middleware
- XJson API - Advanced JSON serialization for BigInt and large data
- Global APIs - Runtime globals overview
- Configuration API (cfg) - Deep dive into the configuration manager
- Immutability API (const) - Deep dive into the immutability engine
- File Upload - Complete file upload guide with runtime compatibility
- Security - CORS, CSRF, rate limiting, and security best practices
- Multi-Server - Running multiple server instances
- Configuration - Complete configuration reference
Additional Resources
- Wildcard CORS - Advanced CORS configuration
- API Reference - Complete API documentation
- Examples - Code examples and use cases
- Migration Guide - Migrating from FortifyJS
Quick Examples
Routing
import { createServer, Router } from "xypriss";
const app = createServer();
const userRouter = Router();
userRouter.get("/:id", (req, res) => {
res.json({ userId: req.params.id });
});
app.use("/api/users", userRouter);File Upload
import { createServer, FileUploadAPI } from "xypriss";
const app = createServer({
fileUpload: {
enabled: true,
maxFileSize: 5 * 1024 * 1024, // 5MB
},
});
const upload = new FileUploadAPI();
await upload.initialize(app.configs?.fileUpload);
app.post("/upload", upload.single("file"), (req, res) => {
res.json({ success: true, file: req.file });
});Security
const server = createServer({
security: {
enabled: true,
level: "enhanced",
cors: {
origin: ["localhost:*", "*.myapp.com"],
credentials: true,
},
rateLimit: { max: 100, windowMs: 15 * 60 * 1000 },
},
});Multi-Server
const app = createServer({
multiServer: {
enabled: true,
servers: [
{
id: "api-server",
port: 3001,
routePrefix: "/api",
allowedRoutes: ["/api/*"],
},
{
id: "admin-server",
port: 3002,
routePrefix: "/admin",
security: { level: "maximum" },
},
],
},
});
await app.startAllServers();Modules
ACPES (Advanced Cross-Platform Encrypted Storage)
Secure storage solution for web, mobile, and Node.js environments.
import { Storage, STORAGE_KEYS } from "xypriss-acpes";
await Storage.setItem(STORAGE_KEYS.SESSION_TOKEN, "secure-token");
const token = await Storage.getItem(STORAGE_KEYS.SESSION_TOKEN);Security Module
Advanced security utilities for data handling and request protection.
import { fString, generateSecureToken } from "xypriss-security";
const secureData = fString(data, { enableEncryption: true });
const token = generateSecureToken({ length: 32 });→ Security Module Documentation
Performance
XyPriss is designed for efficiency and scalability:
- Independent HTTP Server: No Express dependency
- Clustering: Automatic scaling based on CPU cores
- Caching: Memory, Redis, or hybrid strategies
- Auto Port Switching: Detects and switches ports if conflicts arise
const server = createServer({
server: {
port: 3000,
autoPortSwitch: { enabled: true, portRange: [3000, 3100] },
},
cache: {
strategy: "redis",
maxSize: 100 * 1024 * 1024, // 100MB
ttl: 3600,
},
cluster: { enabled: true, workers: "auto" },
});Works Great With Express
XyPriss complements the Node.js ecosystem:
- Use XyPriss standalone for new projects
- Enhance existing Express apps with XyPriss security modules
- Run both frameworks side by side
- Migrate gradually
import express from "express";
import { XyPrissSecurity } from "xypriss-security";
const app = express();
app.use(
XyPrissSecurity.middleware({
csrf: true,
xss: true,
rateLimit: { windowMs: 15 * 60 * 1000, max: 100 },
})
);Contributing
We welcome contributions! See the Contributing Guide for details.
Support
- Documentation - Complete guides and API reference
- GitHub Issues - Bug reports and feature requests
- Security Advisories - Report security vulnerabilities
- Discussions - Community support
License
XyPriss is licensed under the MIT License.