xypriss 2.2.0 → 2.2.1
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/dist/cjs/src/plugins/modules/network/builtin/CompressionPlugin.js +2 -110
- package/dist/cjs/src/plugins/modules/network/builtin/CompressionPlugin.js.map +1 -1
- package/dist/cjs/src/plugins/modules/network/builtin/ConnectionPlugin.js.map +1 -1
- package/dist/cjs/src/plugins/modules/network/core/NetworkPlugin.js.map +1 -1
- package/dist/cjs/src/plugins/modules/network/types/NetworkTypes.js.map +1 -1
- package/dist/cjs/src/server/FastServer.js +10 -10
- package/dist/cjs/src/server/FastServer.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/RouteManager.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/smart-routes.js.map +1 -1
- package/dist/cjs/src/server/core/HttpServer.js +13 -0
- package/dist/cjs/src/server/core/HttpServer.js.map +1 -1
- package/dist/cjs/src/server/core/XyprissApp.js.map +1 -1
- package/dist/cjs/src/server/handlers/NotFoundHandler.js.map +1 -1
- package/dist/cjs/src/server/optimization/RequestPreCompiler.js +1 -0
- package/dist/cjs/src/server/optimization/RequestPreCompiler.js.map +1 -1
- package/dist/cjs/src/server/utils/ConfigLoader.js +245 -148
- package/dist/cjs/src/server/utils/ConfigLoader.js.map +1 -1
- package/dist/esm/src/plugins/modules/network/builtin/CompressionPlugin.js +2 -110
- package/dist/esm/src/plugins/modules/network/builtin/CompressionPlugin.js.map +1 -1
- package/dist/esm/src/plugins/modules/network/builtin/ConnectionPlugin.js.map +1 -1
- package/dist/esm/src/plugins/modules/network/core/NetworkPlugin.js.map +1 -1
- package/dist/esm/src/plugins/modules/network/types/NetworkTypes.js.map +1 -1
- package/dist/esm/src/server/FastServer.js +10 -10
- package/dist/esm/src/server/FastServer.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/RouteManager.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/smart-routes.js.map +1 -1
- package/dist/esm/src/server/core/HttpServer.js +13 -0
- package/dist/esm/src/server/core/HttpServer.js.map +1 -1
- package/dist/esm/src/server/core/XyprissApp.js.map +1 -1
- package/dist/esm/src/server/handlers/NotFoundHandler.js.map +1 -1
- package/dist/esm/src/server/optimization/RequestPreCompiler.js +1 -0
- package/dist/esm/src/server/optimization/RequestPreCompiler.js.map +1 -1
- package/dist/esm/src/server/utils/ConfigLoader.js +227 -151
- package/dist/esm/src/server/utils/ConfigLoader.js.map +1 -1
- package/dist/index.d.ts +68 -44
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse, Server } from 'http';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { Request, Response, NextFunction as NextFunction$1 } from 'express';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* XyPriss Request interface (Express-compatible)
|
|
@@ -32,6 +31,7 @@ interface XyPrisRequest extends IncomingMessage {
|
|
|
32
31
|
fresh: boolean;
|
|
33
32
|
stale: boolean;
|
|
34
33
|
xhr: boolean;
|
|
34
|
+
get: (name: string) => string | undefined;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* XyPriss Response interface (Express-compatible)
|
|
@@ -50,6 +50,7 @@ interface XyPrisResponse extends ServerResponse {
|
|
|
50
50
|
clearCookie(name: string, options?: any): void;
|
|
51
51
|
locals: Record<string, any>;
|
|
52
52
|
headersSent: boolean;
|
|
53
|
+
get: (name: string) => string | number | string[] | undefined;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* Middleware function type
|
|
@@ -1011,7 +1012,7 @@ interface CompiledRoute {
|
|
|
1011
1012
|
}
|
|
1012
1013
|
interface DynamicResponseGenerator {
|
|
1013
1014
|
pattern: string | RegExp;
|
|
1014
|
-
generator: (req:
|
|
1015
|
+
generator: (req: XyPrisRequest, pattern: RequestPattern) => Promise<any> | any;
|
|
1015
1016
|
priority?: number;
|
|
1016
1017
|
}
|
|
1017
1018
|
interface ResponseTemplate {
|
|
@@ -1067,11 +1068,11 @@ declare class RequestPreCompiler {
|
|
|
1067
1068
|
/**
|
|
1068
1069
|
* Analyze incoming request and update patterns
|
|
1069
1070
|
*/
|
|
1070
|
-
analyzeRequest(req:
|
|
1071
|
+
analyzeRequest(req: XyPrisRequest, res: XyPrisResponse, next: NextFunction): void;
|
|
1071
1072
|
/**
|
|
1072
1073
|
* Get optimized handler for request if available
|
|
1073
1074
|
*/
|
|
1074
|
-
getOptimizedHandler(req:
|
|
1075
|
+
getOptimizedHandler(req: XyPrisRequest): CompiledRoute | null;
|
|
1075
1076
|
/**
|
|
1076
1077
|
* Pre-compile optimized execution paths for hot routes
|
|
1077
1078
|
*/
|
|
@@ -1201,7 +1202,7 @@ type RoutePattern = string | RegExp;
|
|
|
1201
1202
|
interface OptimizedRoute {
|
|
1202
1203
|
pattern: RoutePattern;
|
|
1203
1204
|
methods?: string[];
|
|
1204
|
-
handler?: (req:
|
|
1205
|
+
handler?: (req: XyPrisRequest, res: XyPrisResponse) => any | Promise<any>;
|
|
1205
1206
|
schema?: any;
|
|
1206
1207
|
cacheTTL?: number;
|
|
1207
1208
|
priority?: number;
|
|
@@ -2024,7 +2025,7 @@ interface CacheStrategy {
|
|
|
2024
2025
|
/** Strategy name for identification */
|
|
2025
2026
|
name: string;
|
|
2026
2027
|
/** Condition function to determine if strategy applies */
|
|
2027
|
-
condition: (req:
|
|
2028
|
+
condition: (req: XyPrisRequest) => boolean;
|
|
2028
2029
|
/** TTL for this strategy in seconds */
|
|
2029
2030
|
ttl: number;
|
|
2030
2031
|
/** Tags for cache invalidation */
|
|
@@ -2200,7 +2201,7 @@ interface PaginationInfo {
|
|
|
2200
2201
|
* });
|
|
2201
2202
|
* ```
|
|
2202
2203
|
*/
|
|
2203
|
-
interface EnhancedRequest extends
|
|
2204
|
+
interface EnhancedRequest extends XyPrisRequest {
|
|
2204
2205
|
/** Cache utilities for request-level caching */
|
|
2205
2206
|
cache: {
|
|
2206
2207
|
/** Get cached value by key */
|
|
@@ -2273,7 +2274,7 @@ interface EnhancedRequest extends Request {
|
|
|
2273
2274
|
* });
|
|
2274
2275
|
* ```
|
|
2275
2276
|
*/
|
|
2276
|
-
interface EnhancedResponse extends
|
|
2277
|
+
interface EnhancedResponse extends XyPrisResponse {
|
|
2277
2278
|
/** Cache utilities for response caching */
|
|
2278
2279
|
cache: {
|
|
2279
2280
|
/** Set cache headers and TTL for response */
|
|
@@ -2319,7 +2320,7 @@ interface EnhancedResponse extends Response {
|
|
|
2319
2320
|
* };
|
|
2320
2321
|
* ```
|
|
2321
2322
|
*/
|
|
2322
|
-
type RouteHandler = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction
|
|
2323
|
+
type RouteHandler = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction) => Promise<any> | any;
|
|
2323
2324
|
/**
|
|
2324
2325
|
* Middleware function type with enhanced request/response.
|
|
2325
2326
|
*
|
|
@@ -2340,7 +2341,7 @@ type RouteHandler = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunc
|
|
|
2340
2341
|
* };
|
|
2341
2342
|
* ```
|
|
2342
2343
|
*/
|
|
2343
|
-
type MiddlewareFunction = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction
|
|
2344
|
+
type MiddlewareFunction = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction) => Promise<void> | void;
|
|
2344
2345
|
|
|
2345
2346
|
/**
|
|
2346
2347
|
* @fileoverview Routing-related type definitions for XyPrissJS Express integration
|
|
@@ -2441,7 +2442,7 @@ interface RouteCacheConfig {
|
|
|
2441
2442
|
/** Cache TTL in seconds */
|
|
2442
2443
|
ttl?: number;
|
|
2443
2444
|
/** Cache key generator */
|
|
2444
|
-
key?: string | ((req:
|
|
2445
|
+
key?: string | ((req: XyPrisRequest) => string);
|
|
2445
2446
|
/** Cache tags for invalidation */
|
|
2446
2447
|
tags?: string[];
|
|
2447
2448
|
/** Events that should invalidate this cache */
|
|
@@ -2480,9 +2481,9 @@ interface RouteRateLimitConfig {
|
|
|
2480
2481
|
/** Include legacy rate limit headers */
|
|
2481
2482
|
legacyHeaders?: boolean;
|
|
2482
2483
|
/** Custom key generator for rate limiting */
|
|
2483
|
-
keyGenerator?: (req:
|
|
2484
|
+
keyGenerator?: (req: XyPrisRequest) => string;
|
|
2484
2485
|
/** Function to skip rate limiting for certain requests */
|
|
2485
|
-
skip?: (req:
|
|
2486
|
+
skip?: (req: XyPrisRequest) => boolean;
|
|
2486
2487
|
}
|
|
2487
2488
|
/**
|
|
2488
2489
|
* Route validation configuration interface.
|
|
@@ -2559,7 +2560,7 @@ interface RouteOptions {
|
|
|
2559
2560
|
/** Cache TTL in seconds */
|
|
2560
2561
|
ttl?: number;
|
|
2561
2562
|
/** Cache key generator */
|
|
2562
|
-
key?: string | ((req:
|
|
2563
|
+
key?: string | ((req: XyPrisRequest) => string);
|
|
2563
2564
|
/** Cache tags */
|
|
2564
2565
|
tags?: string[];
|
|
2565
2566
|
/** Cache invalidation events */
|
|
@@ -4574,6 +4575,49 @@ interface UltraFastApp {
|
|
|
4574
4575
|
getServerStats?: () => Promise<any>;
|
|
4575
4576
|
}
|
|
4576
4577
|
|
|
4578
|
+
/**
|
|
4579
|
+
* @fileoverview Main export file for XyPrissJS Express integration types
|
|
4580
|
+
*
|
|
4581
|
+
* This file provides a centralized export point for all Express integration
|
|
4582
|
+
* types, organized into modular categories for better maintainability.
|
|
4583
|
+
*
|
|
4584
|
+
* @version 4.5.11
|
|
4585
|
+
* @author XyPrissJS Team
|
|
4586
|
+
* @since 2025-01-06
|
|
4587
|
+
*
|
|
4588
|
+
* @example
|
|
4589
|
+
* ```typescript
|
|
4590
|
+
* // Import all types
|
|
4591
|
+
* import * as XyPrissTypes from './types';
|
|
4592
|
+
*
|
|
4593
|
+
* // Import specific categories
|
|
4594
|
+
* import { CacheConfig, SecurityConfig } from './types';
|
|
4595
|
+
*
|
|
4596
|
+
* // Import from specific modules
|
|
4597
|
+
* import { PerformanceMetrics } from './types/performance';
|
|
4598
|
+
* import { RouteConfig } from './types/routing';
|
|
4599
|
+
* ```
|
|
4600
|
+
*/
|
|
4601
|
+
|
|
4602
|
+
declare global {
|
|
4603
|
+
const Bun: {
|
|
4604
|
+
spawn: (options: {
|
|
4605
|
+
cmd: string[];
|
|
4606
|
+
env?: Record<string, string>;
|
|
4607
|
+
stdio?: string[];
|
|
4608
|
+
}) => BunSubprocess;
|
|
4609
|
+
};
|
|
4610
|
+
}
|
|
4611
|
+
type BunSubprocess = {
|
|
4612
|
+
exited: Promise<number | null>;
|
|
4613
|
+
kill: (signal?: string) => void;
|
|
4614
|
+
killed: boolean;
|
|
4615
|
+
pid: number;
|
|
4616
|
+
stdout?: ReadableStream<Uint8Array>;
|
|
4617
|
+
stderr?: ReadableStream<Uint8Array>;
|
|
4618
|
+
stdin?: WritableStream<Uint8Array>;
|
|
4619
|
+
};
|
|
4620
|
+
|
|
4577
4621
|
/**
|
|
4578
4622
|
* XyPrissJS Cluster Manager
|
|
4579
4623
|
* cluster management for Express applications with advanced monitoring
|
|
@@ -4931,9 +4975,9 @@ declare enum PluginPriority {
|
|
|
4931
4975
|
* Plugin execution context with performance tracking
|
|
4932
4976
|
*/
|
|
4933
4977
|
interface PluginExecutionContext {
|
|
4934
|
-
req:
|
|
4935
|
-
res:
|
|
4936
|
-
next: NextFunction
|
|
4978
|
+
req: XyPrisRequest;
|
|
4979
|
+
res: XyPrisResponse;
|
|
4980
|
+
next: NextFunction;
|
|
4937
4981
|
startTime: number;
|
|
4938
4982
|
executionId: string;
|
|
4939
4983
|
cache: SecureCacheAdapter;
|
|
@@ -5954,7 +5998,7 @@ interface SafeJsonOptions {
|
|
|
5954
5998
|
/**
|
|
5955
5999
|
* Creates middleware that safely handles JSON serialization
|
|
5956
6000
|
*/
|
|
5957
|
-
declare function createSafeJsonMiddleware(options?: SafeJsonOptions): (req:
|
|
6001
|
+
declare function createSafeJsonMiddleware(options?: SafeJsonOptions): (req: XyPrisRequest, res: XyPrisResponse, next: NextFunction) => void;
|
|
5958
6002
|
/**
|
|
5959
6003
|
* Quick setup function for common use cases
|
|
5960
6004
|
*/
|
|
@@ -5966,11 +6010,11 @@ declare function safeJsonStringify(obj: any, options?: SafeJsonOptions): string;
|
|
|
5966
6010
|
/**
|
|
5967
6011
|
* Enhanced res.json replacement that can be used manually
|
|
5968
6012
|
*/
|
|
5969
|
-
declare function sendSafeJson(res:
|
|
6013
|
+
declare function sendSafeJson(res: XyPrisResponse, obj: any, options?: SafeJsonOptions): void;
|
|
5970
6014
|
/**
|
|
5971
6015
|
* Middleware specifically for debugging circular references
|
|
5972
6016
|
*/
|
|
5973
|
-
declare function createCircularRefDebugger(): (req:
|
|
6017
|
+
declare function createCircularRefDebugger(): (req: XyPrisRequest, res: XyPrisResponse, next: NextFunction) => void;
|
|
5974
6018
|
|
|
5975
6019
|
/**
|
|
5976
6020
|
* **CONVENIENCE FUNCTIONS: Quick access to common serialization patterns**
|
|
@@ -6739,7 +6783,7 @@ declare class SecureString {
|
|
|
6739
6783
|
/**
|
|
6740
6784
|
* Generates a cryptographically secure salt
|
|
6741
6785
|
*/
|
|
6742
|
-
static generateSalt(length?: number, format?: HashOutputFormat): string | Uint8Array
|
|
6786
|
+
static generateSalt(length?: number, format?: HashOutputFormat): string | Uint8Array;
|
|
6743
6787
|
/**
|
|
6744
6788
|
* Performs constant-time hash comparison
|
|
6745
6789
|
*/
|
|
@@ -9649,7 +9693,7 @@ declare class PluginEngine extends EventEmitter {
|
|
|
9649
9693
|
/**
|
|
9650
9694
|
* Execute plugins for a specific type with ultra-fast performance
|
|
9651
9695
|
*/
|
|
9652
|
-
executePlugins(type: PluginType, req:
|
|
9696
|
+
executePlugins(type: PluginType, req: XyPrisRequest, res: XyPrisResponse, next: NextFunction): Promise<boolean>;
|
|
9653
9697
|
/**
|
|
9654
9698
|
* Execute a single plugin with comprehensive error handling
|
|
9655
9699
|
*/
|
|
@@ -10260,7 +10304,7 @@ declare class ConnectionPlugin extends NetworkPlugin {
|
|
|
10260
10304
|
/**
|
|
10261
10305
|
* Serve a static file with proper headers and caching
|
|
10262
10306
|
*/
|
|
10263
|
-
serveStaticFile(resource: string, res:
|
|
10307
|
+
serveStaticFile(resource: string, res: XyPrisResponse): Promise<boolean>;
|
|
10264
10308
|
/**
|
|
10265
10309
|
* Cleanup resources
|
|
10266
10310
|
*/
|
|
@@ -10318,26 +10362,6 @@ declare class CompressionPlugin extends NetworkPlugin {
|
|
|
10318
10362
|
* Match content type with pattern (supports wildcards)
|
|
10319
10363
|
*/
|
|
10320
10364
|
private matchesContentType;
|
|
10321
|
-
/**
|
|
10322
|
-
* Select best compression algorithm based on client support and preferences
|
|
10323
|
-
*/
|
|
10324
|
-
private selectCompressionAlgorithm;
|
|
10325
|
-
/**
|
|
10326
|
-
* Apply compression to response
|
|
10327
|
-
*/
|
|
10328
|
-
private applyCompression;
|
|
10329
|
-
/**
|
|
10330
|
-
* Create compression stream for algorithm
|
|
10331
|
-
*/
|
|
10332
|
-
private createCompressionStream;
|
|
10333
|
-
/**
|
|
10334
|
-
* Intercept response to apply compression
|
|
10335
|
-
*/
|
|
10336
|
-
private interceptResponse;
|
|
10337
|
-
/**
|
|
10338
|
-
* Update compression statistics
|
|
10339
|
-
*/
|
|
10340
|
-
private updateCompressionStats;
|
|
10341
10365
|
/**
|
|
10342
10366
|
* Get compression configuration
|
|
10343
10367
|
*/
|
|
@@ -10787,4 +10811,4 @@ declare function quickServer(port?: number): UltraFastApp | MultiServerApp;
|
|
|
10787
10811
|
declare function Router(): XyPrissRouter;
|
|
10788
10812
|
|
|
10789
10813
|
export { CachePlugin as CachePluginBase, CompressionPlugin, ConnectionPlugin, DEFAULT_PLUGIN_CONFIG, JWTAuthPlugin, NetworkCategory, NetworkPlugin, NetworkPluginFactory, NetworkPluginUtils, PERFORMANCE_TARGETS, PLUGIN_SYSTEM_NAME, PLUGIN_SYSTEM_VERSION, PerformanceMonitor, PerformancePlugin as PerformancePluginBase, PluginDevelopmentHelpers, PluginEngine, PluginEventType, PluginPriority, PluginRegistry, PluginSystemFactory, PluginSystemUtils, PluginType, ProxyPlugin, RateLimitPlugin, ResponseTimePlugin, Route, Router, SecurityMiddleware, SecurityPlugin as SecurityPluginBase, SmartCachePlugin, XyPrissRouter, createCacheMiddleware, createCircularRefDebugger, createOptimalCache, createSafeJsonMiddleware, createServer, createServerInstance, expressStringify, fastStringify, quickServer, safeJsonStringify, safeStringify, sendSafeJson, setupSafeJson };
|
|
10790
|
-
export type { BasePlugin, CacheConfig, CachePlugin$1 as CachePlugin, CompressionAlgorithm, CompressionConfig, ConnectionConfig, FailoverConfig, HTTPCacheConfig, HealthCheckConfig, CachePlugin$1 as ICachePlugin, PerformancePlugin$1 as IPerformancePlugin, SecurityPlugin$1 as ISecurityPlugin, LoadBalancingStrategy, MultiServerApp, MultiServerConfig, NativePlugin, NetworkExecutionContext, NetworkExecutionResult, NetworkHealthStatus, NetworkPluginConfig, NetworkSecurityConfig, NextFunction, PerformanceConfig, PerformanceMetrics, PerformancePlugin$1 as PerformancePlugin, PluginConfiguration, PluginEvent, PluginExecutionContext, PluginExecutionResult, PluginExecutionStats, PluginInitializationContext, PluginRegistryConfig, ProxyConfig, RateLimitConfig, RateLimitRule, RateLimitStrategy, RedisConfig, XyPrisRequest as Request, RequestHandler, XyPrisResponse as Response, RouteConfig, RouteOptions, SecurityConfig, SecurityPlugin$1 as SecurityPlugin, ServerOptions, SmartRouteConfig, UltraFastApp, UpstreamServer, WebSocketConfig, MultiServerApp as XyPMS };
|
|
10814
|
+
export type { BasePlugin, CacheConfig, CachePlugin$1 as CachePlugin, CompressionAlgorithm, CompressionConfig, ConnectionConfig, FailoverConfig, HTTPCacheConfig, HealthCheckConfig, CachePlugin$1 as ICachePlugin, PerformancePlugin$1 as IPerformancePlugin, SecurityPlugin$1 as ISecurityPlugin, LoadBalancingStrategy, MultiServerApp, MultiServerConfig, NativePlugin, NetworkExecutionContext, NetworkExecutionResult, NetworkHealthStatus, NetworkPluginConfig, NetworkSecurityConfig, NextFunction, PerformanceConfig, PerformanceMetrics, PerformancePlugin$1 as PerformancePlugin, PluginConfiguration, PluginEvent, PluginExecutionContext, PluginExecutionResult, PluginExecutionStats, PluginInitializationContext, PluginRegistryConfig, ProxyConfig, RateLimitConfig, RateLimitRule, RateLimitStrategy, RedisConfig, XyPrisRequest as Request, RequestHandler, XyPrisResponse as Response, RouteConfig, RouteOptions, SecurityConfig, SecurityPlugin$1 as SecurityPlugin, ServerOptions, SmartRouteConfig, UltraFastApp, UpstreamServer, WebSocketConfig, MultiServerApp as XyPMS, XyPrisRequest as XyPrissRequest, XyPrisResponse as XyPrissResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xypriss",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "XyPriss is a lightweight, TypeScript-first, open-source Node.js web framework crafted for developers seeking a familiar Express-like API without Express dependencies. It features built-in security middleware, a robust routing system, and performance optimizations to build scalable, secure web applications effortlessly. Join our community and contribute on GitHub!",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -231,7 +231,6 @@
|
|
|
231
231
|
"csurf": "^1.11.0",
|
|
232
232
|
"elliptic": "^6.6.1",
|
|
233
233
|
"entropy-string": "^4.2.0",
|
|
234
|
-
"express": "^5.1.0",
|
|
235
234
|
"express-brute": "^1.0.1",
|
|
236
235
|
"express-csrf-double-submit-cookie": "^2.0.0",
|
|
237
236
|
"express-mongo-sanitize": "^2.2.0",
|