xypriss 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -447
- package/dist/cjs/src/FiUp.js +85 -0
- package/dist/cjs/src/FiUp.js.map +1 -0
- package/dist/cjs/src/file-upload.js +14 -87
- package/dist/cjs/src/file-upload.js.map +1 -1
- package/dist/cjs/src/index.js +8 -5
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/server/FastServer.js +9 -5
- package/dist/cjs/src/server/FastServer.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/FileUploadManager.js +31 -19
- package/dist/cjs/src/server/components/fastapi/FileUploadManager.js.map +1 -1
- package/dist/cjs/src/server/const/default.js +10 -6
- package/dist/cjs/src/server/const/default.js.map +1 -1
- package/dist/cjs/src/server/core/HttpServer.js +16 -7
- package/dist/cjs/src/server/core/HttpServer.js.map +1 -1
- package/dist/cjs/src/server/core/XyprissApp.js +2 -1
- package/dist/cjs/src/server/core/XyprissApp.js.map +1 -1
- package/dist/esm/src/FiUp.js +79 -0
- package/dist/esm/src/FiUp.js.map +1 -0
- package/dist/esm/src/file-upload.js +9 -83
- package/dist/esm/src/file-upload.js.map +1 -1
- package/dist/esm/src/index.js +3 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/server/FastServer.js +9 -5
- package/dist/esm/src/server/FastServer.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/FileUploadManager.js +31 -19
- package/dist/esm/src/server/components/fastapi/FileUploadManager.js.map +1 -1
- package/dist/esm/src/server/const/default.js +10 -6
- package/dist/esm/src/server/const/default.js.map +1 -1
- package/dist/esm/src/server/core/HttpServer.js +16 -7
- package/dist/esm/src/server/core/HttpServer.js.map +1 -1
- package/dist/esm/src/server/core/XyprissApp.js +2 -1
- package/dist/esm/src/server/core/XyprissApp.js.map +1 -1
- package/dist/index.d.ts +154 -99
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -16,33 +16,31 @@ A powerful Node.js web framework with built-in security, clustering, and perform
|
|
|
16
16
|
|
|
17
17
|
## Overview
|
|
18
18
|
|
|
19
|
-
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.
|
|
19
|
+
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.
|
|
20
20
|
|
|
21
21
|
### Key Features
|
|
22
22
|
|
|
23
|
-
- **Familiar API**: Intuitive syntax for defining routes and middleware
|
|
24
|
-
- **Built-in Security**:
|
|
25
|
-
- **File Upload Support**: Seamless
|
|
26
|
-
- **Multi-Server Mode**: Run multiple server instances with different configurations
|
|
27
|
-
- **Flexible Routing**:
|
|
28
|
-
- **TypeScript Support**: Full type definitions for
|
|
29
|
-
- **Performance**: Advanced clustering, caching, and
|
|
23
|
+
- **Familiar API**: Intuitive syntax for defining routes and middleware
|
|
24
|
+
- **Built-in Security**: 12+ security middleware modules (CSRF, XSS, rate limiting)
|
|
25
|
+
- **File Upload Support**: Seamless multipart/form-data handling with automatic error handling
|
|
26
|
+
- **Multi-Server Mode**: Run multiple server instances with different configurations
|
|
27
|
+
- **Flexible Routing**: Parameters, wildcards, and modular routers
|
|
28
|
+
- **TypeScript Support**: Full type definitions for better DX
|
|
29
|
+
- **Performance**: Advanced clustering, caching, and optimizations
|
|
30
30
|
|
|
31
|
-
> **Note**: XyPriss is the successor to FortifyJS, which will be deprecated.
|
|
31
|
+
> **Note**: XyPriss is the successor to FortifyJS, which will be deprecated. [Migration Guide](https://github.com/nehonix/FortifyJS)
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
35
|
## Installation
|
|
36
36
|
|
|
37
|
-
Install XyPriss via npm or yarn:
|
|
38
|
-
|
|
39
37
|
```bash
|
|
40
38
|
npm install xypriss
|
|
41
39
|
# or
|
|
42
40
|
yarn add xypriss
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
For additional security features
|
|
43
|
+
For additional security features:
|
|
46
44
|
|
|
47
45
|
```bash
|
|
48
46
|
npm install xypriss-security
|
|
@@ -52,38 +50,24 @@ npm install xypriss-security
|
|
|
52
50
|
|
|
53
51
|
## Quick Start
|
|
54
52
|
|
|
55
|
-
### 🚀 Recommended: Use XyPriss CLI
|
|
56
|
-
|
|
57
|
-
The fastest way to get started with XyPriss is using our CLI tool:
|
|
53
|
+
### 🚀 Recommended: Use XyPriss CLI
|
|
58
54
|
|
|
59
55
|
```bash
|
|
60
56
|
# Install the CLI globally
|
|
61
57
|
npm install -g xypriss-cli
|
|
62
58
|
|
|
63
|
-
# Create a new
|
|
59
|
+
# Create a new project
|
|
64
60
|
xypcli init
|
|
65
61
|
|
|
66
|
-
#
|
|
67
|
-
# Choose TypeScript/JavaScript
|
|
68
|
-
|
|
69
|
-
# Start development server
|
|
62
|
+
# Start development
|
|
70
63
|
cd your-project-name
|
|
71
64
|
npm run dev
|
|
72
65
|
```
|
|
73
66
|
|
|
74
|
-
The CLI automatically generates a complete project structure with
|
|
75
|
-
|
|
76
|
-
- ✅ Pre-configured TypeScript/JavaScript setup
|
|
77
|
-
- ✅ Authentication system (optional)
|
|
78
|
-
- ✅ File upload support (optional)
|
|
79
|
-
- ✅ Multi-server configuration (optional)
|
|
80
|
-
- ✅ All dependencies installed
|
|
81
|
-
- ✅ Ready-to-run development server
|
|
67
|
+
The CLI automatically generates a complete project structure with authentication, file upload support, and multi-server configuration (all optional).
|
|
82
68
|
|
|
83
69
|
### Manual Setup
|
|
84
70
|
|
|
85
|
-
If you prefer manual setup, create a basic server with XyPriss:
|
|
86
|
-
|
|
87
71
|
```typescript
|
|
88
72
|
import { createServer } from "xypriss";
|
|
89
73
|
|
|
@@ -102,112 +86,30 @@ server.start(() => {
|
|
|
102
86
|
});
|
|
103
87
|
```
|
|
104
88
|
|
|
105
|
-
This sets up a server with security middleware and clustering enabled, listening on port 3000.
|
|
106
|
-
|
|
107
|
-
### Works Great With Express
|
|
108
|
-
|
|
109
|
-
XyPriss is designed to complement the Node.js ecosystem, not replace it. You can:
|
|
110
|
-
|
|
111
|
-
- **Use XyPriss standalone** for new projects that need built-in security and clustering
|
|
112
|
-
- **Enhance existing Express apps** by integrating XyPriss security modules
|
|
113
|
-
- **Run both frameworks** side by side for different services
|
|
114
|
-
- **Migrate gradually** by moving specific routes or services to XyPriss
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
// Example: Using XyPriss security with Express
|
|
118
|
-
import express from "express";
|
|
119
|
-
import { XyPrissSecurity } from "xypriss-security";
|
|
120
|
-
|
|
121
|
-
const app = express();
|
|
122
|
-
|
|
123
|
-
// Add XyPriss security to your Express app
|
|
124
|
-
app.use(
|
|
125
|
-
XyPrissSecurity.middleware({
|
|
126
|
-
csrf: true,
|
|
127
|
-
xss: true,
|
|
128
|
-
rateLimit: { windowMs: 15 * 60 * 1000, max: 100 },
|
|
129
|
-
})
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
app.listen(3000);
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## Table of Contents
|
|
138
|
-
|
|
139
|
-
- [Overview](#overview)
|
|
140
|
-
- [Installation](#installation)
|
|
141
|
-
- [Quick Start](#quick-start)
|
|
142
|
-
- [Routing](#routing)
|
|
143
|
-
- [File Upload](#file-upload)
|
|
144
|
-
- [Multi-Server](#multi-server)
|
|
145
|
-
- [Security](#security)
|
|
146
|
-
- [Performance](#performance)
|
|
147
|
-
- [Configuration](#configuration)
|
|
148
|
-
- [Modules](#modules)
|
|
149
|
-
- [Contributing](#contributing)
|
|
150
|
-
- [License](#license)
|
|
151
|
-
- [Support](#support)
|
|
152
|
-
|
|
153
89
|
---
|
|
154
90
|
|
|
155
|
-
##
|
|
156
|
-
|
|
157
|
-
XyPriss provides a flexible routing system with support for parameters, wildcards, and modular routers.
|
|
91
|
+
## Documentation
|
|
158
92
|
|
|
159
|
-
###
|
|
93
|
+
### Core Guides
|
|
160
94
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
95
|
+
- **[Routing](./docs/ROUTING.md)** - Routes, parameters, wildcards, and middleware
|
|
96
|
+
- **[File Upload](./docs/FILE_UPLOAD_GUIDE.md)** - Complete file upload guide with runtime compatibility
|
|
97
|
+
- **[Security](./docs/SECURITY.md)** - CORS, CSRF, rate limiting, and security best practices
|
|
98
|
+
- **[Multi-Server](./docs/MULTI_SERVER.md)** - Running multiple server instances
|
|
99
|
+
- **[Configuration](./docs/CONFIGURATION.md)** - Complete configuration reference
|
|
165
100
|
|
|
166
|
-
|
|
167
|
-
res.json({ message: "Welcome to XyPriss" });
|
|
168
|
-
});
|
|
101
|
+
### Additional Resources
|
|
169
102
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
103
|
+
- **[Wildcard CORS](./docs/WILDCARD_CORS.md)** - Advanced CORS configuration
|
|
104
|
+
- **[API Reference](./docs/API.md)** - Complete API documentation
|
|
105
|
+
- **[Examples](./examples/)** - Code examples and use cases
|
|
106
|
+
- **[Migration Guide](./docs/MIGRATION.md)** - Migrating from FortifyJS
|
|
173
107
|
|
|
174
|
-
|
|
175
|
-
res.json({ message: "User updated", id: req.params.id });
|
|
176
|
-
});
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Route Parameters
|
|
180
|
-
|
|
181
|
-
Extract dynamic segments from URLs:
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
app.get("/users/:id", (req, res) => {
|
|
185
|
-
res.json({ userId: req.params.id });
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
app.get("/users/:userId/posts/:postId", (req, res) => {
|
|
189
|
-
res.json({ userId: req.params.userId, postId: req.params.postId });
|
|
190
|
-
});
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Wildcard Routes
|
|
194
|
-
|
|
195
|
-
- **Single Wildcard (`*`)**: Matches one path segment.
|
|
196
|
-
- **Multi-segment Wildcard (`**`)\*\*: Matches multiple path segments.
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
app.get("/files/*", (req, res) => {
|
|
200
|
-
res.json({ filename: req.params["*"] }); // e.g., "document.pdf"
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
app.get("/api/**", (req, res) => {
|
|
204
|
-
res.json({ path: req.params["**"] }); // e.g., "v1/users/123"
|
|
205
|
-
});
|
|
206
|
-
```
|
|
108
|
+
---
|
|
207
109
|
|
|
208
|
-
|
|
110
|
+
## Quick Examples
|
|
209
111
|
|
|
210
|
-
|
|
112
|
+
### Routing
|
|
211
113
|
|
|
212
114
|
```typescript
|
|
213
115
|
import { createServer, Router } from "xypriss";
|
|
@@ -215,159 +117,58 @@ import { createServer, Router } from "xypriss";
|
|
|
215
117
|
const app = createServer();
|
|
216
118
|
const userRouter = Router();
|
|
217
119
|
|
|
218
|
-
userRouter.get("/", (req, res) => {
|
|
219
|
-
res.json({ message: "List users" });
|
|
220
|
-
});
|
|
221
|
-
|
|
222
120
|
userRouter.get("/:id", (req, res) => {
|
|
223
|
-
res.json({
|
|
121
|
+
res.json({ userId: req.params.id });
|
|
224
122
|
});
|
|
225
123
|
|
|
226
124
|
app.use("/api/users", userRouter);
|
|
227
125
|
```
|
|
228
126
|
|
|
229
|
-
|
|
127
|
+
[→ Full Routing Guide](./docs/ROUTING.md)
|
|
230
128
|
|
|
231
|
-
|
|
129
|
+
### File Upload
|
|
232
130
|
|
|
233
131
|
```typescript
|
|
234
|
-
|
|
235
|
-
app.use((req, res, next) => {
|
|
236
|
-
console.log(`${req.method} ${req.path}`);
|
|
237
|
-
next();
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// Route-specific middleware
|
|
241
|
-
app.get(
|
|
242
|
-
"/protected",
|
|
243
|
-
(req, res, next) => {
|
|
244
|
-
if (!req.headers.authorization) {
|
|
245
|
-
return res.status(401).json({ error: "Unauthorized" });
|
|
246
|
-
}
|
|
247
|
-
next();
|
|
248
|
-
},
|
|
249
|
-
(req, res) => {
|
|
250
|
-
res.json({ message: "Protected resource" });
|
|
251
|
-
}
|
|
252
|
-
);
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## File Upload
|
|
258
|
-
|
|
259
|
-
XyPriss provides powerful file upload support with **automatic error handling** and both class-based and functional APIs. No manual error handling required!
|
|
260
|
-
|
|
261
|
-
### Quick Start (Class-Based API - Recommended)
|
|
262
|
-
|
|
263
|
-
```typescript
|
|
264
|
-
import { createServer } from "xypriss";
|
|
265
|
-
import { FileUploadAPI } from "xypriss";
|
|
132
|
+
import { createServer, FileUploadAPI } from "xypriss";
|
|
266
133
|
|
|
267
134
|
const app = createServer({
|
|
268
135
|
fileUpload: {
|
|
269
136
|
enabled: true,
|
|
270
137
|
maxFileSize: 5 * 1024 * 1024, // 5MB
|
|
271
|
-
allowedMimeTypes: ["image/jpeg", "image/png"],
|
|
272
138
|
},
|
|
273
139
|
});
|
|
274
140
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
await fileUpload.initialize(app.options.fileUpload);
|
|
278
|
-
|
|
279
|
-
app.post("/upload", fileUpload.single("file"), (req, res) => {
|
|
280
|
-
// Automatic error handling - only success code here!
|
|
281
|
-
res.json({
|
|
282
|
-
success: true,
|
|
283
|
-
message: "File uploaded successfully",
|
|
284
|
-
file: {
|
|
285
|
-
name: req.file.originalname,
|
|
286
|
-
size: req.file.size,
|
|
287
|
-
type: req.file.mimetype,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
});
|
|
141
|
+
const upload = new FileUploadAPI();
|
|
142
|
+
await upload.initialize(app.configs?.fileUpload);
|
|
291
143
|
|
|
292
|
-
app.
|
|
144
|
+
app.post("/upload", upload.single("file"), (req, res) => {
|
|
145
|
+
res.json({ success: true, file: req.file });
|
|
146
|
+
});
|
|
293
147
|
```
|
|
294
148
|
|
|
295
|
-
|
|
149
|
+
[→ Full File Upload Guide](./docs/FILE_UPLOAD_GUIDE.md)
|
|
296
150
|
|
|
297
|
-
|
|
298
|
-
import { createServer } from "xypriss";
|
|
299
|
-
import { uploadSingle } from "xypriss";
|
|
151
|
+
### Security
|
|
300
152
|
|
|
301
|
-
|
|
302
|
-
|
|
153
|
+
```typescript
|
|
154
|
+
const server = createServer({
|
|
155
|
+
security: {
|
|
303
156
|
enabled: true,
|
|
304
|
-
|
|
305
|
-
|
|
157
|
+
level: "enhanced",
|
|
158
|
+
cors: {
|
|
159
|
+
origin: ["localhost:*", "*.myapp.com"],
|
|
160
|
+
credentials: true,
|
|
161
|
+
},
|
|
162
|
+
rateLimit: { max: 100, windowMs: 15 * 60 * 1000 },
|
|
306
163
|
},
|
|
307
164
|
});
|
|
308
|
-
|
|
309
|
-
app.post("/upload", uploadSingle("file"), (req, res) => {
|
|
310
|
-
// Automatic error handling - no try/catch needed!
|
|
311
|
-
res.json({
|
|
312
|
-
success: true,
|
|
313
|
-
file: req.file,
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
app.start();
|
|
318
165
|
```
|
|
319
166
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
**File Too Large:**
|
|
323
|
-
|
|
324
|
-
```json
|
|
325
|
-
{
|
|
326
|
-
"success": false,
|
|
327
|
-
"error": "File too large",
|
|
328
|
-
"message": "File size exceeds the maximum limit of 1.00MB",
|
|
329
|
-
"details": {
|
|
330
|
-
"maxSize": 1048576,
|
|
331
|
-
"maxSizeMB": "1.00",
|
|
332
|
-
"fileSize": "unknown"
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
```
|
|
167
|
+
[→ Full Security Guide](./docs/SECURITY.md)
|
|
336
168
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
```json
|
|
340
|
-
{
|
|
341
|
-
"success": false,
|
|
342
|
-
"error": "File type not allowed",
|
|
343
|
-
"message": "File type 'application/exe' not allowed. Allowed types: image/jpeg, image/png"
|
|
344
|
-
}
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
### Features
|
|
348
|
-
|
|
349
|
-
- ✅ **Automatic Error Handling**: Multer errors converted to user-friendly JSON responses
|
|
350
|
-
- ✅ **Class-Based API**: Modern `FileUploadAPI` class for better organization
|
|
351
|
-
- ✅ **Legacy Compatibility**: Functional API still available for simple use cases
|
|
352
|
-
- ✅ **Multipart Support**: Fixed multipart/form-data handling (no more "Unexpected end of form" errors)
|
|
353
|
-
- ✅ **Security**: Built-in file validation, type checking, and size limits
|
|
354
|
-
- ✅ **Flexible Storage**: Memory, disk, or custom storage backends
|
|
355
|
-
- ✅ **Type Safety**: Full TypeScript support with proper type definitions
|
|
356
|
-
- ✅ **Performance**: Optimized for large file uploads with streaming support
|
|
357
|
-
|
|
358
|
-
For comprehensive documentation, configuration options, and advanced usage, see the [File Upload Guide](./docs/file-upload.md).
|
|
359
|
-
|
|
360
|
-
---
|
|
361
|
-
|
|
362
|
-
## Multi-Server
|
|
363
|
-
|
|
364
|
-
Run multiple server instances with different configurations from a single setup. Perfect for microservices, API versioning, or separating concerns.
|
|
365
|
-
|
|
366
|
-
### Basic Multi-Server Setup
|
|
169
|
+
### Multi-Server
|
|
367
170
|
|
|
368
171
|
```typescript
|
|
369
|
-
import { createServer } from "xypriss";
|
|
370
|
-
|
|
371
172
|
const app = createServer({
|
|
372
173
|
multiServer: {
|
|
373
174
|
enabled: true,
|
|
@@ -382,113 +183,57 @@ const app = createServer({
|
|
|
382
183
|
id: "admin-server",
|
|
383
184
|
port: 3002,
|
|
384
185
|
routePrefix: "/admin",
|
|
385
|
-
allowedRoutes: ["/admin/*"],
|
|
386
186
|
security: { level: "maximum" },
|
|
387
187
|
},
|
|
388
188
|
],
|
|
389
189
|
},
|
|
390
190
|
});
|
|
391
191
|
|
|
392
|
-
// Routes are automatically distributed to appropriate servers
|
|
393
|
-
app.get("/api/users", (req, res) => res.json({ service: "api" }));
|
|
394
|
-
app.get("/admin/dashboard", (req, res) => res.json({ service: "admin" }));
|
|
395
|
-
|
|
396
|
-
// Start all servers with a simple API
|
|
397
192
|
await app.startAllServers();
|
|
398
193
|
```
|
|
399
194
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
- **Simple API**: `startAllServers()` and `stopAllServers()` hide complexity
|
|
403
|
-
- **Automatic Route Distribution**: Routes are filtered and distributed automatically
|
|
404
|
-
- **Server-Specific Overrides**: Each server can have different security, cache, and performance settings
|
|
405
|
-
- **Microservices Ready**: Perfect for API versioning and service separation
|
|
406
|
-
- **Load Balancing**: Built-in support for reverse proxy load balancing
|
|
407
|
-
|
|
408
|
-
For comprehensive multi-server documentation, see the [Multi-Server Guide](./docs/multi-server.md).
|
|
195
|
+
[→ Full Multi-Server Guide](./docs/MULTI_SERVER.md)
|
|
409
196
|
|
|
410
197
|
---
|
|
411
198
|
|
|
412
|
-
##
|
|
413
|
-
|
|
414
|
-
XyPriss includes 12 built-in security middleware modules to protect your application:
|
|
199
|
+
## Modules
|
|
415
200
|
|
|
416
|
-
|
|
417
|
-
- **Security Headers**: Powered by Helmet for secure HTTP headers.
|
|
418
|
-
- **CORS**: Configurable cross-origin resource sharing with wildcard pattern support.
|
|
419
|
-
- **Rate Limiting**: Prevents abuse by limiting requests per IP.
|
|
420
|
-
- **Input Validation**: Sanitizes inputs to prevent XSS and injection attacks.
|
|
421
|
-
- **Request Logging**: Monitors and logs incoming requests.
|
|
201
|
+
### ACPES (Advanced Cross-Platform Encrypted Storage)
|
|
422
202
|
|
|
423
|
-
|
|
203
|
+
Secure storage solution for web, mobile, and Node.js environments.
|
|
424
204
|
|
|
425
205
|
```typescript
|
|
426
|
-
import {
|
|
427
|
-
|
|
428
|
-
const server = createServer({
|
|
429
|
-
security: {
|
|
430
|
-
enabled: true,
|
|
431
|
-
csrf: { enabled: true },
|
|
432
|
-
rateLimit: { max: 100, windowMs: 15 * 60 * 1000 }, // 100 requests per 15 minutes
|
|
433
|
-
},
|
|
434
|
-
});
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
### CORS with Wildcard Support
|
|
438
|
-
|
|
439
|
-
XyPriss supports flexible CORS configuration with wildcard patterns:
|
|
206
|
+
import { Storage, STORAGE_KEYS } from "xypriss-acpes";
|
|
440
207
|
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
security: {
|
|
444
|
-
cors: {
|
|
445
|
-
origin: [
|
|
446
|
-
"localhost:*", // Any localhost port
|
|
447
|
-
"127.0.0.1:*", // Any 127.0.0.1 port
|
|
448
|
-
"*.myapp.com", // Any subdomain
|
|
449
|
-
"https://app.prod.com", // Exact production URL
|
|
450
|
-
],
|
|
451
|
-
credentials: true,
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
});
|
|
208
|
+
await Storage.setItem(STORAGE_KEYS.SESSION_TOKEN, "secure-token");
|
|
209
|
+
const token = await Storage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
455
210
|
```
|
|
456
211
|
|
|
457
|
-
|
|
212
|
+
[→ ACPES Documentation](./mods/ACPES/docs/)
|
|
458
213
|
|
|
459
|
-
|
|
460
|
-
- `*.domain.com` - Matches any subdomain
|
|
461
|
-
- Exact URLs for production environments
|
|
462
|
-
|
|
463
|
-
For detailed CORS configuration, see the [Wildcard CORS Guide](./docs/WILDCARD_CORS.md).
|
|
214
|
+
### Security Module
|
|
464
215
|
|
|
465
|
-
|
|
216
|
+
Advanced security utilities for data handling and request protection.
|
|
466
217
|
|
|
467
218
|
```typescript
|
|
468
|
-
import { createServer } from "xypriss";
|
|
469
219
|
import { fString, generateSecureToken } from "xypriss-security";
|
|
470
220
|
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
server.post("/api/secure", async (req, res) => {
|
|
474
|
-
const secureData = fString(req.body.data, { enableEncryption: true });
|
|
475
|
-
const token = generateSecureToken({ length: 32 });
|
|
476
|
-
res.json({ token, data: secureData });
|
|
477
|
-
});
|
|
221
|
+
const secureData = fString(data, { enableEncryption: true });
|
|
222
|
+
const token = generateSecureToken({ length: 32 });
|
|
478
223
|
```
|
|
479
224
|
|
|
225
|
+
[→ Security Module Documentation](./mods/security/docs/)
|
|
226
|
+
|
|
480
227
|
---
|
|
481
228
|
|
|
482
229
|
## Performance
|
|
483
230
|
|
|
484
231
|
XyPriss is designed for efficiency and scalability:
|
|
485
232
|
|
|
486
|
-
- **Independent HTTP Server**: No Express dependency
|
|
487
|
-
- **Clustering**: Automatic scaling based on CPU cores
|
|
488
|
-
- **Caching**:
|
|
489
|
-
- **Auto Port Switching**: Detects and switches ports if conflicts arise
|
|
490
|
-
|
|
491
|
-
Example configuration:
|
|
233
|
+
- **Independent HTTP Server**: No Express dependency
|
|
234
|
+
- **Clustering**: Automatic scaling based on CPU cores
|
|
235
|
+
- **Caching**: Memory, Redis, or hybrid strategies
|
|
236
|
+
- **Auto Port Switching**: Detects and switches ports if conflicts arise
|
|
492
237
|
|
|
493
238
|
```typescript
|
|
494
239
|
const server = createServer({
|
|
@@ -497,160 +242,66 @@ const server = createServer({
|
|
|
497
242
|
autoPortSwitch: { enabled: true, portRange: [3000, 3100] },
|
|
498
243
|
},
|
|
499
244
|
cache: {
|
|
500
|
-
strategy: "
|
|
245
|
+
strategy: "redis",
|
|
501
246
|
maxSize: 100 * 1024 * 1024, // 100MB
|
|
502
|
-
ttl: 3600,
|
|
247
|
+
ttl: 3600,
|
|
503
248
|
},
|
|
504
249
|
cluster: { enabled: true, workers: "auto" },
|
|
505
250
|
});
|
|
506
251
|
```
|
|
507
252
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
## Configuration
|
|
511
|
-
|
|
512
|
-
Customize XyPriss with the `ServerOptions` interface:
|
|
513
|
-
|
|
514
|
-
```typescript
|
|
515
|
-
interface ServerOptions {
|
|
516
|
-
env?: "development" | "production" | "test";
|
|
517
|
-
server?: {
|
|
518
|
-
port?: number;
|
|
519
|
-
host?: string;
|
|
520
|
-
autoPortSwitch?: {
|
|
521
|
-
enabled: boolean;
|
|
522
|
-
portRange?: [number, number];
|
|
523
|
-
strategy?: "increment" | "random";
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
cache?: {
|
|
527
|
-
strategy?: "memory" | "redis" | "hybrid";
|
|
528
|
-
maxSize?: number;
|
|
529
|
-
ttl?: number;
|
|
530
|
-
redis?: { host: string; port: number; cluster?: boolean };
|
|
531
|
-
};
|
|
532
|
-
security?: {
|
|
533
|
-
enabled?: boolean;
|
|
534
|
-
csrf?: { enabled: boolean };
|
|
535
|
-
rateLimit?: { max: number; windowMs: number };
|
|
536
|
-
};
|
|
537
|
-
cluster?: {
|
|
538
|
-
enabled: boolean;
|
|
539
|
-
workers?: number | "auto";
|
|
540
|
-
};
|
|
541
|
-
fileUpload?: {
|
|
542
|
-
maxFileSize?: number;
|
|
543
|
-
allowedMimeTypes?: string[];
|
|
544
|
-
storage?: {
|
|
545
|
-
type?: "memory" | "disk" | "cloud";
|
|
546
|
-
destination?: string;
|
|
547
|
-
filename?: (req: any, file: any, cb: any) => void;
|
|
548
|
-
};
|
|
549
|
-
validation?: {
|
|
550
|
-
enabled?: boolean;
|
|
551
|
-
maxFiles?: number;
|
|
552
|
-
minFileSize?: number;
|
|
553
|
-
virusScan?: boolean;
|
|
554
|
-
};
|
|
555
|
-
security?: {
|
|
556
|
-
sanitizeFilename?: boolean;
|
|
557
|
-
removeExif?: boolean;
|
|
558
|
-
watermark?: boolean;
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
multiServer?: {
|
|
562
|
-
enabled: boolean;
|
|
563
|
-
servers: Array<{
|
|
564
|
-
id: string;
|
|
565
|
-
port: number;
|
|
566
|
-
host?: string;
|
|
567
|
-
routePrefix?: string;
|
|
568
|
-
allowedRoutes?: string[];
|
|
569
|
-
server?: object;
|
|
570
|
-
security?: object;
|
|
571
|
-
cache?: object;
|
|
572
|
-
performance?: object;
|
|
573
|
-
fileUpload?: object;
|
|
574
|
-
}>;
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
Example:
|
|
580
|
-
|
|
581
|
-
```typescript
|
|
582
|
-
const server = createServer({
|
|
583
|
-
env: "production",
|
|
584
|
-
server: { port: 8080, host: "0.0.0.0" },
|
|
585
|
-
cache: { strategy: "redis", redis: { host: "localhost", port: 6379 } },
|
|
586
|
-
});
|
|
587
|
-
```
|
|
253
|
+
[→ Full Configuration Guide](./docs/CONFIGURATION.md)
|
|
588
254
|
|
|
589
255
|
---
|
|
590
256
|
|
|
591
|
-
##
|
|
257
|
+
## Works Great With Express
|
|
592
258
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
**Location**: `mods/ACPES/`
|
|
596
|
-
|
|
597
|
-
A secure storage solution for web, mobile, and Node.js environments.
|
|
259
|
+
XyPriss complements the Node.js ecosystem:
|
|
598
260
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
-
|
|
602
|
-
-
|
|
603
|
-
- TTL for automatic data expiration.
|
|
604
|
-
- LZ-string compression for large data.
|
|
605
|
-
|
|
606
|
-
**Usage**:
|
|
261
|
+
- Use XyPriss standalone for new projects
|
|
262
|
+
- Enhance existing Express apps with XyPriss security modules
|
|
263
|
+
- Run both frameworks side by side
|
|
264
|
+
- Migrate gradually
|
|
607
265
|
|
|
608
266
|
```typescript
|
|
609
|
-
import
|
|
610
|
-
|
|
611
|
-
await Storage.setItem(STORAGE_KEYS.SESSION_TOKEN, "secure-token");
|
|
612
|
-
const token = await Storage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
**Docs**: [ACPES Documentation](./mods/ACPES/docs/)
|
|
616
|
-
|
|
617
|
-
### Security Module
|
|
618
|
-
|
|
619
|
-
**Location**: `mods/security/`
|
|
620
|
-
|
|
621
|
-
Provides utilities for secure data handling and request protection.
|
|
622
|
-
|
|
623
|
-
**Features**:
|
|
267
|
+
import express from "express";
|
|
268
|
+
import { XyPrissSecurity } from "xypriss-security";
|
|
624
269
|
|
|
625
|
-
|
|
626
|
-
- Cryptographic functions (e.g., secure token generation).
|
|
627
|
-
- Rate limiting and DDoS protection.
|
|
270
|
+
const app = express();
|
|
628
271
|
|
|
629
|
-
|
|
272
|
+
app.use(
|
|
273
|
+
XyPrissSecurity.middleware({
|
|
274
|
+
csrf: true,
|
|
275
|
+
xss: true,
|
|
276
|
+
rateLimit: { windowMs: 15 * 60 * 1000, max: 100 },
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
```
|
|
630
280
|
|
|
631
281
|
---
|
|
632
282
|
|
|
633
283
|
## Contributing
|
|
634
284
|
|
|
635
|
-
We welcome contributions! See the [Contributing Guide](./CONTRIBUTING.md) for details
|
|
285
|
+
We welcome contributions! See the [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
636
286
|
|
|
637
287
|
---
|
|
638
288
|
|
|
639
|
-
##
|
|
289
|
+
## Support
|
|
640
290
|
|
|
641
|
-
|
|
291
|
+
- **[Documentation](./docs/)** - Complete guides and API reference
|
|
292
|
+
- **[GitHub Issues](https://github.com/Nehonix-Team/XyPriss/issues)** - Bug reports and feature requests
|
|
293
|
+
- **[Security Advisories](https://github.com/Nehonix-Team/XyPriss/security)** - Report security vulnerabilities
|
|
294
|
+
- **[Discussions](https://github.com/Nehonix-Team/XyPriss/discussions)** - Community support
|
|
642
295
|
|
|
643
296
|
---
|
|
644
297
|
|
|
645
|
-
##
|
|
298
|
+
## License
|
|
646
299
|
|
|
647
|
-
|
|
648
|
-
- [GitHub Issues](https://github.com/Nehonix-Team/XyPriss/issues)
|
|
649
|
-
- [Security Advisories](https://github.com/Nehonix-Team/XyPriss/security)
|
|
300
|
+
XyPriss is licensed under the [MIT License](./LICENSE).
|
|
650
301
|
|
|
651
302
|
---
|
|
652
303
|
|
|
653
|
-
### Powered by Nehonix
|
|
304
|
+
### Powered by Nehonix Devs
|
|
654
305
|
|
|
655
306
|
[](https://nehonix.com)
|
|
656
307
|
[](https://github.com/Nehonix-Team)
|