xypriss 2.1.2 → 2.2.0

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.
Files changed (29) hide show
  1. package/README.md +139 -0
  2. package/dist/cjs/src/server/FastServer.js +69 -0
  3. package/dist/cjs/src/server/FastServer.js.map +1 -1
  4. package/dist/cjs/src/server/ServerFactory.js +218 -2
  5. package/dist/cjs/src/server/ServerFactory.js.map +1 -1
  6. package/dist/cjs/src/server/components/fastapi/FileUploadManager.js +175 -0
  7. package/dist/cjs/src/server/components/fastapi/FileUploadManager.js.map +1 -0
  8. package/dist/cjs/src/server/components/lifecycle/ServerLifecycleManager.js.map +1 -1
  9. package/dist/cjs/src/server/components/multi-server/MultiServerManager.js +200 -0
  10. package/dist/cjs/src/server/components/multi-server/MultiServerManager.js.map +1 -0
  11. package/dist/cjs/src/server/const/default.js +35 -0
  12. package/dist/cjs/src/server/const/default.js.map +1 -1
  13. package/dist/cjs/src/server/core/HttpServer.js +6 -1
  14. package/dist/cjs/src/server/core/HttpServer.js.map +1 -1
  15. package/dist/esm/src/server/FastServer.js +69 -0
  16. package/dist/esm/src/server/FastServer.js.map +1 -1
  17. package/dist/esm/src/server/ServerFactory.js +218 -2
  18. package/dist/esm/src/server/ServerFactory.js.map +1 -1
  19. package/dist/esm/src/server/components/fastapi/FileUploadManager.js +154 -0
  20. package/dist/esm/src/server/components/fastapi/FileUploadManager.js.map +1 -0
  21. package/dist/esm/src/server/components/lifecycle/ServerLifecycleManager.js.map +1 -1
  22. package/dist/esm/src/server/components/multi-server/MultiServerManager.js +198 -0
  23. package/dist/esm/src/server/components/multi-server/MultiServerManager.js.map +1 -0
  24. package/dist/esm/src/server/const/default.js +35 -0
  25. package/dist/esm/src/server/const/default.js.map +1 -1
  26. package/dist/esm/src/server/core/HttpServer.js +6 -1
  27. package/dist/esm/src/server/core/HttpServer.js.map +1 -1
  28. package/dist/index.d.ts +814 -492
  29. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1571,315 +1571,94 @@ interface RouteSecurityConfig {
1571
1571
  }
1572
1572
 
1573
1573
  /**
1574
- * @fileoverview Core type definitions for XyPrissJS Express integration
1574
+ * @fileoverview Performance-related type definitions for XyPrissJS Express integration
1575
1575
  *
1576
- * This module contains fundamental types and utilities used throughout
1577
- * the Express integration system.
1576
+ * This module contains all performance-related types including monitoring,
1577
+ * optimization, metrics, and configuration.
1578
1578
  *
1579
1579
  * @version 4.5.11
1580
1580
  * @author XyPrissJS Team
1581
1581
  * @since 2025-01-06
1582
1582
  */
1583
-
1584
- /**
1585
- * Deep partial utility type that makes all properties optional recursively.
1586
- *
1587
- * This utility type is used throughout the configuration system to allow
1588
- * partial configuration objects while maintaining type safety.
1589
- *
1590
- * @template T - The type to make deeply partial
1591
- *
1592
- * @example
1593
- * ```typescript
1594
- * interface Config {
1595
- * server: {
1596
- * port: number;
1597
- * host: string;
1598
- * };
1599
- * }
1600
- *
1601
- * type PartialConfig = DeepPartial<Config>;
1602
- * // Result: { server?: { port?: number; host?: string; } }
1603
- * ```
1604
- */
1605
- type DeepPartial<T> = {
1606
- [K in keyof T]?: T[K] extends infer U ? U extends object ? U extends readonly any[] ? U extends readonly (infer V)[] ? readonly DeepPartial<V>[] : U : U extends Function ? U : DeepPartial<U> : U : never;
1607
- };
1608
1583
  /**
1609
- * Validation result interface for request validation operations.
1610
- *
1611
- * Used by validation middleware and request handlers to provide
1612
- * structured validation feedback.
1613
- *
1614
- * @interface ValidationResult
1615
- *
1616
- * @example
1617
- * ```typescript
1618
- * const result: ValidationResult = {
1619
- * valid: false,
1620
- * errors: ['Email is required', 'Password too short'],
1621
- * data: { email: '', password: '123' }
1622
- * };
1623
- * ```
1624
- */
1625
- interface ValidationResult$1 {
1626
- /** Whether the validation passed */
1627
- valid: boolean;
1628
- /** Array of validation error messages */
1629
- errors: string[];
1630
- /** The validated/sanitized data */
1631
- data: any;
1632
- }
1633
- /**
1634
- * User context information for authenticated requests.
1635
- *
1636
- * Contains user identity, permissions, and metadata for
1637
- * authorization and audit purposes.
1638
- *
1639
- * @interface UserContext
1640
- *
1641
- * @example
1642
- * ```typescript
1643
- * const user: UserContext = {
1644
- * id: 'user-123',
1645
- * roles: ['admin', 'user'],
1646
- * permissions: ['read:users', 'write:posts'],
1647
- * metadata: { department: 'engineering', level: 'senior' }
1648
- * };
1649
- * ```
1650
- */
1651
- interface UserContext {
1652
- /** Unique user identifier */
1653
- id: string;
1654
- /** Array of user roles */
1655
- roles: string[];
1656
- /** Array of specific permissions */
1657
- permissions: string[];
1658
- /** Additional user metadata */
1659
- metadata: Record<string, any>;
1660
- }
1661
- /**
1662
- * Session data structure for user sessions.
1663
- *
1664
- * Contains session information including expiration and
1665
- * custom session data.
1666
- *
1667
- * @interface SessionData
1668
- *
1669
- * @example
1670
- * ```typescript
1671
- * const session: SessionData = {
1672
- * id: 'session-abc123',
1673
- * userId: 'user-123',
1674
- * data: { theme: 'dark', language: 'en' },
1675
- * expires: new Date(Date.now() + 3600000) // 1 hour
1676
- * };
1677
- * ```
1678
- */
1679
- interface SessionData {
1680
- /** Unique session identifier */
1681
- id: string;
1682
- /** Associated user ID (optional) */
1683
- userId?: string;
1684
- /** Custom session data */
1685
- data: Record<string, any>;
1686
- /** Session expiration date */
1687
- expires: Date;
1688
- }
1689
- /**
1690
- * Pagination information for paginated responses.
1691
- *
1692
- * Used by API endpoints that return paginated data to provide
1693
- * navigation information to clients.
1694
- *
1695
- * @interface PaginationInfo
1696
- *
1697
- * @example
1698
- * ```typescript
1699
- * const pagination: PaginationInfo = {
1700
- * page: 2,
1701
- * limit: 20,
1702
- * total: 150,
1703
- * pages: 8
1704
- * };
1705
- * ```
1706
- */
1707
- interface PaginationInfo {
1708
- /** Current page number (1-based) */
1709
- page: number;
1710
- /** Number of items per page */
1711
- limit: number;
1712
- /** Total number of items */
1713
- total: number;
1714
- /** Total number of pages */
1715
- pages: number;
1716
- }
1717
- /**
1718
- * Enhanced Express request interface with additional utilities.
1584
+ * Performance configuration interface.
1719
1585
  *
1720
- * Extends the standard Express Request with caching, security,
1721
- * performance, and validation utilities.
1586
+ * Comprehensive configuration for performance monitoring,
1587
+ * optimization, and metrics collection.
1722
1588
  *
1723
- * @interface EnhancedRequest
1724
- * @extends Request
1589
+ * @interface PerformanceConfig
1725
1590
  *
1726
1591
  * @example
1727
1592
  * ```typescript
1728
- * app.get('/api/users', async (req: EnhancedRequest, res: EnhancedResponse) => {
1729
- * // Use enhanced features
1730
- * const cached = await req.cache.get('users');
1731
- * const encrypted = await req.security.encrypt(sensitiveData);
1732
- * req.performance.start();
1733
- *
1734
- * // Validation
1735
- * const validation = req.validation.query(userQuerySchema);
1736
- * if (!validation.valid) {
1737
- * return res.error('Invalid query parameters');
1593
+ * const perfConfig: PerformanceConfig = {
1594
+ * enabled: true,
1595
+ * metrics: ['response_time', 'memory_usage', 'cpu_usage'],
1596
+ * interval: 30000, // 30 seconds
1597
+ * alerts: [
1598
+ * {
1599
+ * metric: 'response_time',
1600
+ * threshold: 1000, // 1 second
1601
+ * action: 'log',
1602
+ * cooldown: 300000 // 5 minutes
1603
+ * }
1604
+ * ],
1605
+ * dashboard: true,
1606
+ * export: {
1607
+ * custom: (metrics) => {
1608
+ * console.log('Custom metrics export:', metrics);
1609
+ * }
1738
1610
  * }
1739
- * });
1740
- * ```
1741
- */
1742
- interface EnhancedRequest extends Request {
1743
- /** Cache utilities for request-level caching */
1744
- cache: {
1745
- /** Get cached value by key */
1746
- get: (key: string) => Promise<any>;
1747
- /** Set cached value with optional TTL */
1748
- set: (key: string, value: any, ttl?: number) => Promise<void>;
1749
- /** Delete cached value */
1750
- del: (key: string) => Promise<void>;
1751
- /** Tag cache entries for bulk invalidation */
1752
- tags: (tags: string[]) => Promise<void>;
1753
- };
1754
- /** Security utilities for encryption and authentication */
1755
- security: {
1756
- /** Encrypt data using configured algorithm */
1757
- encrypt: (data: any) => Promise<string>;
1758
- /** Decrypt data using configured algorithm */
1759
- decrypt: (data: string) => Promise<any>;
1760
- /** Hash data using secure algorithm */
1761
- hash: (data: string) => string;
1762
- /** Verify data against hash */
1763
- verify: (data: string, hash: string) => boolean;
1764
- /** Generate secure token */
1765
- generateToken: () => string;
1766
- /** Session encryption key */
1767
- sessionKey: string;
1768
- };
1769
- /** Performance monitoring utilities */
1770
- performance: {
1771
- /** Start performance timer */
1772
- start: () => void;
1773
- /** End performance timer and return duration */
1774
- end: () => number;
1775
- /** Mark a performance point */
1776
- mark: (name: string) => void;
1777
- /** Measure time between marks */
1778
- measure: (name: string, start: string, end: string) => number;
1779
- };
1780
- /** Request validation utilities */
1781
- validation: {
1782
- /** Validate request body against schema */
1783
- body: (schema: any) => ValidationResult$1;
1784
- /** Validate query parameters against schema */
1785
- query: (schema: any) => ValidationResult$1;
1786
- /** Validate route parameters against schema */
1787
- params: (schema: any) => ValidationResult$1;
1788
- };
1789
- /** User context (available after authentication) */
1790
- user?: UserContext;
1791
- /** Session data (available when sessions are enabled) */
1792
- session?: SessionData;
1793
- }
1794
- /**
1795
- * Enhanced Express response interface with additional utilities.
1796
- *
1797
- * Extends the standard Express Response with caching, security,
1798
- * performance, and convenience methods.
1799
- *
1800
- * @interface EnhancedResponse
1801
- * @extends Response
1802
- *
1803
- * @example
1804
- * ```typescript
1805
- * app.get('/api/users', async (req: EnhancedRequest, res: EnhancedResponse) => {
1806
- * const users = await getUsersFromDB();
1807
- *
1808
- * // Use enhanced response methods
1809
- * res.cache.set(3600, ['users']); // Cache for 1 hour with 'users' tag
1810
- * res.performance.timing('db_query', 150);
1811
- * res.success(users, 'Users retrieved successfully');
1812
- * });
1611
+ * };
1813
1612
  * ```
1814
1613
  */
1815
- interface EnhancedResponse extends Response {
1816
- /** Cache utilities for response caching */
1817
- cache: {
1818
- /** Set cache headers and TTL for response */
1819
- set: (ttl?: number, tags?: string[]) => void;
1820
- /** Invalidate cache entries by tags */
1821
- invalidate: (tags: string[]) => Promise<void>;
1822
- };
1823
- /** Security utilities for response encryption */
1824
- security: {
1825
- /** Encrypt response data */
1826
- encrypt: (data: any) => EnhancedResponse;
1827
- /** Sign response data */
1828
- sign: (data: any) => EnhancedResponse;
1829
- };
1830
- /** Performance utilities for response metrics */
1831
- performance: {
1832
- /** Record timing metric */
1833
- timing: (name: string, value: number) => void;
1834
- /** Record custom metric */
1835
- metric: (name: string, value: number) => void;
1614
+ interface PerformanceConfig {
1615
+ /** Enable performance monitoring */
1616
+ enabled?: boolean;
1617
+ /** Metrics to collect */
1618
+ metrics?: string[];
1619
+ /** Collection interval in milliseconds */
1620
+ interval?: number;
1621
+ /** Alert configurations */
1622
+ alerts?: AlertConfig[];
1623
+ /** Enable performance dashboard */
1624
+ dashboard?: boolean;
1625
+ /** Export configuration */
1626
+ export?: {
1627
+ /** Custom export function */
1628
+ custom?: (metrics: any) => void;
1836
1629
  };
1837
- /** Send successful response with optional message */
1838
- success: (data?: any, message?: string) => void;
1839
- /** Send error response with message and status code */
1840
- error: (error: string | Error, code?: number) => void;
1841
- /** Send paginated response with pagination info */
1842
- paginated: (data: any[], pagination: PaginationInfo) => void;
1843
1630
  }
1844
1631
  /**
1845
- * Route handler function type with enhanced request/response.
1846
- *
1847
- * @template T - Return type of the handler
1848
- *
1849
- * @example
1850
- * ```typescript
1851
- * const getUserHandler: RouteHandler = async (req, res, next) => {
1852
- * try {
1853
- * const user = await getUserById(req.params.id);
1854
- * res.success(user);
1855
- * } catch (error) {
1856
- * next(error);
1857
- * }
1858
- * };
1859
- * ```
1860
- */
1861
- type RouteHandler = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction$1) => Promise<any> | any;
1862
- /**
1863
- * Middleware function type with enhanced request/response.
1864
- *
1865
- * @example
1866
- * ```typescript
1867
- * const authMiddleware: MiddlewareFunction = async (req, res, next) => {
1868
- * const token = req.headers.authorization;
1869
- * if (!token) {
1870
- * return res.error('Authorization required', 401);
1871
- * }
1632
+ * Alert configuration interface.
1872
1633
  *
1873
- * try {
1874
- * req.user = await verifyToken(token);
1875
- * next();
1876
- * } catch (error) {
1877
- * res.error('Invalid token', 401);
1878
- * }
1634
+ * Configuration for performance alerts including thresholds,
1635
+ * actions, and cooldown periods.
1636
+ *
1637
+ * @interface AlertConfig
1638
+ *
1639
+ * @example
1640
+ * ```typescript
1641
+ * const alertConfig: AlertConfig = {
1642
+ * metric: 'memory_usage',
1643
+ * threshold: 0.85, // 85%
1644
+ * action: 'webhook',
1645
+ * target: 'https://alerts.example.com/webhook',
1646
+ * cooldown: 600000 // 10 minutes
1879
1647
  * };
1880
1648
  * ```
1881
1649
  */
1882
- type MiddlewareFunction = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction$1) => Promise<void> | void;
1650
+ interface AlertConfig {
1651
+ /** Metric name to monitor */
1652
+ metric: string;
1653
+ /** Threshold value that triggers alert */
1654
+ threshold: number;
1655
+ /** Action to take when alert triggers */
1656
+ action: "log" | "email" | "webhook" | "custom";
1657
+ /** Target for the action (email, webhook URL, etc.) */
1658
+ target?: string;
1659
+ /** Cooldown period in milliseconds */
1660
+ cooldown?: number;
1661
+ }
1883
1662
 
1884
1663
  /**
1885
1664
  * @fileoverview Cache-related type definitions for XyPrissJS Express integration
@@ -2253,94 +2032,315 @@ interface CacheStrategy {
2253
2032
  }
2254
2033
 
2255
2034
  /**
2256
- * @fileoverview Performance-related type definitions for XyPrissJS Express integration
2035
+ * @fileoverview Core type definitions for XyPrissJS Express integration
2257
2036
  *
2258
- * This module contains all performance-related types including monitoring,
2259
- * optimization, metrics, and configuration.
2037
+ * This module contains fundamental types and utilities used throughout
2038
+ * the Express integration system.
2260
2039
  *
2261
2040
  * @version 4.5.11
2262
2041
  * @author XyPrissJS Team
2263
2042
  * @since 2025-01-06
2264
2043
  */
2044
+
2045
+ /**
2046
+ * Deep partial utility type that makes all properties optional recursively.
2047
+ *
2048
+ * This utility type is used throughout the configuration system to allow
2049
+ * partial configuration objects while maintaining type safety.
2050
+ *
2051
+ * @template T - The type to make deeply partial
2052
+ *
2053
+ * @example
2054
+ * ```typescript
2055
+ * interface Config {
2056
+ * server: {
2057
+ * port: number;
2058
+ * host: string;
2059
+ * };
2060
+ * }
2061
+ *
2062
+ * type PartialConfig = DeepPartial<Config>;
2063
+ * // Result: { server?: { port?: number; host?: string; } }
2064
+ * ```
2065
+ */
2066
+ type DeepPartial<T> = {
2067
+ [K in keyof T]?: T[K] extends infer U ? U extends object ? U extends readonly any[] ? U extends readonly (infer V)[] ? readonly DeepPartial<V>[] : U : U extends Function ? U : DeepPartial<U> : U : never;
2068
+ };
2069
+ /**
2070
+ * Validation result interface for request validation operations.
2071
+ *
2072
+ * Used by validation middleware and request handlers to provide
2073
+ * structured validation feedback.
2074
+ *
2075
+ * @interface ValidationResult
2076
+ *
2077
+ * @example
2078
+ * ```typescript
2079
+ * const result: ValidationResult = {
2080
+ * valid: false,
2081
+ * errors: ['Email is required', 'Password too short'],
2082
+ * data: { email: '', password: '123' }
2083
+ * };
2084
+ * ```
2085
+ */
2086
+ interface ValidationResult$1 {
2087
+ /** Whether the validation passed */
2088
+ valid: boolean;
2089
+ /** Array of validation error messages */
2090
+ errors: string[];
2091
+ /** The validated/sanitized data */
2092
+ data: any;
2093
+ }
2094
+ /**
2095
+ * User context information for authenticated requests.
2096
+ *
2097
+ * Contains user identity, permissions, and metadata for
2098
+ * authorization and audit purposes.
2099
+ *
2100
+ * @interface UserContext
2101
+ *
2102
+ * @example
2103
+ * ```typescript
2104
+ * const user: UserContext = {
2105
+ * id: 'user-123',
2106
+ * roles: ['admin', 'user'],
2107
+ * permissions: ['read:users', 'write:posts'],
2108
+ * metadata: { department: 'engineering', level: 'senior' }
2109
+ * };
2110
+ * ```
2111
+ */
2112
+ interface UserContext {
2113
+ /** Unique user identifier */
2114
+ id: string;
2115
+ /** Array of user roles */
2116
+ roles: string[];
2117
+ /** Array of specific permissions */
2118
+ permissions: string[];
2119
+ /** Additional user metadata */
2120
+ metadata: Record<string, any>;
2121
+ }
2122
+ /**
2123
+ * Session data structure for user sessions.
2124
+ *
2125
+ * Contains session information including expiration and
2126
+ * custom session data.
2127
+ *
2128
+ * @interface SessionData
2129
+ *
2130
+ * @example
2131
+ * ```typescript
2132
+ * const session: SessionData = {
2133
+ * id: 'session-abc123',
2134
+ * userId: 'user-123',
2135
+ * data: { theme: 'dark', language: 'en' },
2136
+ * expires: new Date(Date.now() + 3600000) // 1 hour
2137
+ * };
2138
+ * ```
2139
+ */
2140
+ interface SessionData {
2141
+ /** Unique session identifier */
2142
+ id: string;
2143
+ /** Associated user ID (optional) */
2144
+ userId?: string;
2145
+ /** Custom session data */
2146
+ data: Record<string, any>;
2147
+ /** Session expiration date */
2148
+ expires: Date;
2149
+ }
2150
+ /**
2151
+ * Pagination information for paginated responses.
2152
+ *
2153
+ * Used by API endpoints that return paginated data to provide
2154
+ * navigation information to clients.
2155
+ *
2156
+ * @interface PaginationInfo
2157
+ *
2158
+ * @example
2159
+ * ```typescript
2160
+ * const pagination: PaginationInfo = {
2161
+ * page: 2,
2162
+ * limit: 20,
2163
+ * total: 150,
2164
+ * pages: 8
2165
+ * };
2166
+ * ```
2167
+ */
2168
+ interface PaginationInfo {
2169
+ /** Current page number (1-based) */
2170
+ page: number;
2171
+ /** Number of items per page */
2172
+ limit: number;
2173
+ /** Total number of items */
2174
+ total: number;
2175
+ /** Total number of pages */
2176
+ pages: number;
2177
+ }
2178
+ /**
2179
+ * Enhanced Express request interface with additional utilities.
2180
+ *
2181
+ * Extends the standard Express Request with caching, security,
2182
+ * performance, and validation utilities.
2183
+ *
2184
+ * @interface EnhancedRequest
2185
+ * @extends Request
2186
+ *
2187
+ * @example
2188
+ * ```typescript
2189
+ * app.get('/api/users', async (req: EnhancedRequest, res: EnhancedResponse) => {
2190
+ * // Use enhanced features
2191
+ * const cached = await req.cache.get('users');
2192
+ * const encrypted = await req.security.encrypt(sensitiveData);
2193
+ * req.performance.start();
2194
+ *
2195
+ * // Validation
2196
+ * const validation = req.validation.query(userQuerySchema);
2197
+ * if (!validation.valid) {
2198
+ * return res.error('Invalid query parameters');
2199
+ * }
2200
+ * });
2201
+ * ```
2202
+ */
2203
+ interface EnhancedRequest extends Request {
2204
+ /** Cache utilities for request-level caching */
2205
+ cache: {
2206
+ /** Get cached value by key */
2207
+ get: (key: string) => Promise<any>;
2208
+ /** Set cached value with optional TTL */
2209
+ set: (key: string, value: any, ttl?: number) => Promise<void>;
2210
+ /** Delete cached value */
2211
+ del: (key: string) => Promise<void>;
2212
+ /** Tag cache entries for bulk invalidation */
2213
+ tags: (tags: string[]) => Promise<void>;
2214
+ };
2215
+ /** Security utilities for encryption and authentication */
2216
+ security: {
2217
+ /** Encrypt data using configured algorithm */
2218
+ encrypt: (data: any) => Promise<string>;
2219
+ /** Decrypt data using configured algorithm */
2220
+ decrypt: (data: string) => Promise<any>;
2221
+ /** Hash data using secure algorithm */
2222
+ hash: (data: string) => string;
2223
+ /** Verify data against hash */
2224
+ verify: (data: string, hash: string) => boolean;
2225
+ /** Generate secure token */
2226
+ generateToken: () => string;
2227
+ /** Session encryption key */
2228
+ sessionKey: string;
2229
+ };
2230
+ /** Performance monitoring utilities */
2231
+ performance: {
2232
+ /** Start performance timer */
2233
+ start: () => void;
2234
+ /** End performance timer and return duration */
2235
+ end: () => number;
2236
+ /** Mark a performance point */
2237
+ mark: (name: string) => void;
2238
+ /** Measure time between marks */
2239
+ measure: (name: string, start: string, end: string) => number;
2240
+ };
2241
+ /** Request validation utilities */
2242
+ validation: {
2243
+ /** Validate request body against schema */
2244
+ body: (schema: any) => ValidationResult$1;
2245
+ /** Validate query parameters against schema */
2246
+ query: (schema: any) => ValidationResult$1;
2247
+ /** Validate route parameters against schema */
2248
+ params: (schema: any) => ValidationResult$1;
2249
+ };
2250
+ /** User context (available after authentication) */
2251
+ user?: UserContext;
2252
+ /** Session data (available when sessions are enabled) */
2253
+ session?: SessionData;
2254
+ }
2255
+ /**
2256
+ * Enhanced Express response interface with additional utilities.
2257
+ *
2258
+ * Extends the standard Express Response with caching, security,
2259
+ * performance, and convenience methods.
2260
+ *
2261
+ * @interface EnhancedResponse
2262
+ * @extends Response
2263
+ *
2264
+ * @example
2265
+ * ```typescript
2266
+ * app.get('/api/users', async (req: EnhancedRequest, res: EnhancedResponse) => {
2267
+ * const users = await getUsersFromDB();
2268
+ *
2269
+ * // Use enhanced response methods
2270
+ * res.cache.set(3600, ['users']); // Cache for 1 hour with 'users' tag
2271
+ * res.performance.timing('db_query', 150);
2272
+ * res.success(users, 'Users retrieved successfully');
2273
+ * });
2274
+ * ```
2275
+ */
2276
+ interface EnhancedResponse extends Response {
2277
+ /** Cache utilities for response caching */
2278
+ cache: {
2279
+ /** Set cache headers and TTL for response */
2280
+ set: (ttl?: number, tags?: string[]) => void;
2281
+ /** Invalidate cache entries by tags */
2282
+ invalidate: (tags: string[]) => Promise<void>;
2283
+ };
2284
+ /** Security utilities for response encryption */
2285
+ security: {
2286
+ /** Encrypt response data */
2287
+ encrypt: (data: any) => EnhancedResponse;
2288
+ /** Sign response data */
2289
+ sign: (data: any) => EnhancedResponse;
2290
+ };
2291
+ /** Performance utilities for response metrics */
2292
+ performance: {
2293
+ /** Record timing metric */
2294
+ timing: (name: string, value: number) => void;
2295
+ /** Record custom metric */
2296
+ metric: (name: string, value: number) => void;
2297
+ };
2298
+ /** Send successful response with optional message */
2299
+ success: (data?: any, message?: string) => void;
2300
+ /** Send error response with message and status code */
2301
+ error: (error: string | Error, code?: number) => void;
2302
+ /** Send paginated response with pagination info */
2303
+ paginated: (data: any[], pagination: PaginationInfo) => void;
2304
+ }
2265
2305
  /**
2266
- * Performance configuration interface.
2267
- *
2268
- * Comprehensive configuration for performance monitoring,
2269
- * optimization, and metrics collection.
2306
+ * Route handler function type with enhanced request/response.
2270
2307
  *
2271
- * @interface PerformanceConfig
2308
+ * @template T - Return type of the handler
2272
2309
  *
2273
2310
  * @example
2274
2311
  * ```typescript
2275
- * const perfConfig: PerformanceConfig = {
2276
- * enabled: true,
2277
- * metrics: ['response_time', 'memory_usage', 'cpu_usage'],
2278
- * interval: 30000, // 30 seconds
2279
- * alerts: [
2280
- * {
2281
- * metric: 'response_time',
2282
- * threshold: 1000, // 1 second
2283
- * action: 'log',
2284
- * cooldown: 300000 // 5 minutes
2285
- * }
2286
- * ],
2287
- * dashboard: true,
2288
- * export: {
2289
- * custom: (metrics) => {
2290
- * console.log('Custom metrics export:', metrics);
2291
- * }
2312
+ * const getUserHandler: RouteHandler = async (req, res, next) => {
2313
+ * try {
2314
+ * const user = await getUserById(req.params.id);
2315
+ * res.success(user);
2316
+ * } catch (error) {
2317
+ * next(error);
2292
2318
  * }
2293
2319
  * };
2294
2320
  * ```
2295
2321
  */
2296
- interface PerformanceConfig {
2297
- /** Enable performance monitoring */
2298
- enabled?: boolean;
2299
- /** Metrics to collect */
2300
- metrics?: string[];
2301
- /** Collection interval in milliseconds */
2302
- interval?: number;
2303
- /** Alert configurations */
2304
- alerts?: AlertConfig[];
2305
- /** Enable performance dashboard */
2306
- dashboard?: boolean;
2307
- /** Export configuration */
2308
- export?: {
2309
- /** Custom export function */
2310
- custom?: (metrics: any) => void;
2311
- };
2312
- }
2322
+ type RouteHandler = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction$1) => Promise<any> | any;
2313
2323
  /**
2314
- * Alert configuration interface.
2315
- *
2316
- * Configuration for performance alerts including thresholds,
2317
- * actions, and cooldown periods.
2318
- *
2319
- * @interface AlertConfig
2324
+ * Middleware function type with enhanced request/response.
2320
2325
  *
2321
2326
  * @example
2322
2327
  * ```typescript
2323
- * const alertConfig: AlertConfig = {
2324
- * metric: 'memory_usage',
2325
- * threshold: 0.85, // 85%
2326
- * action: 'webhook',
2327
- * target: 'https://alerts.example.com/webhook',
2328
- * cooldown: 600000 // 10 minutes
2328
+ * const authMiddleware: MiddlewareFunction = async (req, res, next) => {
2329
+ * const token = req.headers.authorization;
2330
+ * if (!token) {
2331
+ * return res.error('Authorization required', 401);
2332
+ * }
2333
+ *
2334
+ * try {
2335
+ * req.user = await verifyToken(token);
2336
+ * next();
2337
+ * } catch (error) {
2338
+ * res.error('Invalid token', 401);
2339
+ * }
2329
2340
  * };
2330
2341
  * ```
2331
2342
  */
2332
- interface AlertConfig {
2333
- /** Metric name to monitor */
2334
- metric: string;
2335
- /** Threshold value that triggers alert */
2336
- threshold: number;
2337
- /** Action to take when alert triggers */
2338
- action: "log" | "email" | "webhook" | "custom";
2339
- /** Target for the action (email, webhook URL, etc.) */
2340
- target?: string;
2341
- /** Cooldown period in milliseconds */
2342
- cooldown?: number;
2343
- }
2343
+ type MiddlewareFunction = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction$1) => Promise<void> | void;
2344
2344
 
2345
2345
  /**
2346
2346
  * @fileoverview Routing-related type definitions for XyPrissJS Express integration
@@ -2599,6 +2599,11 @@ interface RouteOptions {
2599
2599
  * Comprehensive types for the fluent middleware management API
2600
2600
  */
2601
2601
  type MiddlewarePriority = "critical" | "high" | "normal" | "low";
2602
+ interface MiddlewareConfiguration {
2603
+ enabled?: boolean;
2604
+ priority?: MiddlewarePriority;
2605
+ order?: number;
2606
+ }
2602
2607
  interface SecurityMiddlewareConfig {
2603
2608
  helmet?: boolean | {
2604
2609
  contentSecurityPolicy?: boolean | object;
@@ -2722,17 +2727,217 @@ interface XyPrissMiddlewareAPI {
2722
2727
  /**
2723
2728
  * Clear all middleware
2724
2729
  */
2725
- clear(): XyPrissMiddlewareAPI;
2730
+ clear(): XyPrissMiddlewareAPI;
2731
+ /**
2732
+ * Optimize middleware order by priority
2733
+ */
2734
+ optimize(): XyPrissMiddlewareAPI;
2735
+ unregister(id: string): XyPrissMiddlewareAPI;
2736
+ enable(id: string): XyPrissMiddlewareAPI;
2737
+ disable(id: string): XyPrissMiddlewareAPI;
2738
+ getInfo(id?: string): any;
2739
+ getStats(): any;
2740
+ getConfig(): any;
2741
+ }
2742
+
2743
+ /**
2744
+ * Centralized Logger for FastApi.ts Server
2745
+ * Provides granular control over logging output with enhanced robustness
2746
+ */
2747
+
2748
+ declare class Logger {
2749
+ private config;
2750
+ private static instance;
2751
+ private buffer;
2752
+ private flushTimer?;
2753
+ private isDisposed;
2754
+ private logQueue;
2755
+ private isProcessingQueue;
2756
+ private errorCount;
2757
+ private lastErrorTime;
2758
+ private suppressedComponents;
2759
+ constructor(config?: ServerOptions["logging"]);
2760
+ /**
2761
+ * Initialize log buffer system
2762
+ */
2763
+ private initializeBuffer;
2764
+ /**
2765
+ * Setup error handling and recovery mechanisms
2766
+ */
2767
+ private setupErrorHandling;
2768
+ /**
2769
+ * Emergency logging that bypasses normal filtering
2770
+ */
2771
+ private emergencyLog;
2772
+ /**
2773
+ * Start auto-flush timer for buffered logging
2774
+ */
2775
+ private startAutoFlush;
2776
+ /**
2777
+ * Flush buffered log entries
2778
+ */
2779
+ flush(): void;
2780
+ /**
2781
+ * Get or create singleton instance
2782
+ */
2783
+ static getInstance(config?: ServerOptions["logging"]): Logger;
2784
+ /**
2785
+ * Deep merge two objects
2786
+ */
2787
+ private deepMerge;
2788
+ /**
2789
+ * Update logger configuration
2790
+ */
2791
+ updateConfig(config: ServerOptions["logging"]): void;
2792
+ /**
2793
+ * Get current logger configuration (for debugging)
2794
+ */
2795
+ getConfig(): ServerOptions["logging"];
2796
+ /**
2797
+ * Check if we should suppress this log due to error rate limiting
2798
+ */
2799
+ private shouldSuppressError;
2800
+ /**
2801
+ * Check if logging is enabled for a specific component and type
2802
+ */
2803
+ private shouldLog;
2804
+ /**
2805
+ * Get memory usage information
2806
+ */
2807
+ private getMemoryInfo;
2808
+ /**
2809
+ * Get process ID
2810
+ */
2811
+ private getProcessId;
2812
+ /**
2813
+ * Truncate message if it exceeds max line length
2814
+ */
2815
+ private truncateMessage;
2816
+ /**
2817
+ * Format log message
2818
+ */
2819
+ private formatMessage;
2820
+ /**
2821
+ * Write log entry to output
2822
+ */
2823
+ private writeLog;
2824
+ /**
2825
+ * Process log queue
2826
+ */
2827
+ private processLogQueue;
2828
+ /**
2829
+ * Log a message
2830
+ */
2831
+ private log;
2832
+ error(component: LogComponent, message: string, ...args: any[]): void;
2833
+ warn(component: LogComponent, message: string, ...args: any[]): void;
2834
+ info(component: LogComponent, message: string, ...args: any[]): void;
2835
+ debug(component: LogComponent, message: string, ...args: any[]): void;
2836
+ verbose(component: LogComponent, message: string, ...args: any[]): void;
2837
+ startup(component: LogComponent, message: string, ...args: any[]): void;
2838
+ performance(component: LogComponent, message: string, ...args: any[]): void;
2839
+ hotReload(component: LogComponent, message: string, ...args: any[]): void;
2840
+ portSwitching(component: LogComponent, message: string, ...args: any[]): void;
2841
+ securityWarning(message: string, ...args: any[]): void;
2842
+ isEnabled(): boolean;
2843
+ getLevel(): LogLevel;
2844
+ isComponentEnabled(component: LogComponent): boolean;
2845
+ isTypeEnabled(type: LogType): boolean;
2846
+ /**
2847
+ * Get logging statistics
2848
+ */
2849
+ getStats(): {
2850
+ errorCount: number;
2851
+ lastErrorTime: number;
2852
+ suppressedComponents: string[];
2853
+ bufferSize: number;
2854
+ queueSize: number;
2855
+ };
2856
+ /**
2857
+ * Clear suppressed components
2858
+ */
2859
+ clearSuppression(): void;
2860
+ /**
2861
+ * Dispose logger and cleanup resources
2862
+ */
2863
+ dispose(): void;
2726
2864
  /**
2727
- * Optimize middleware order by priority
2865
+ * Create a child logger with component-specific configuration
2728
2866
  */
2729
- optimize(): XyPrissMiddlewareAPI;
2730
- unregister(id: string): XyPrissMiddlewareAPI;
2731
- enable(id: string): XyPrissMiddlewareAPI;
2732
- disable(id: string): XyPrissMiddlewareAPI;
2733
- getInfo(id?: string): any;
2734
- getStats(): any;
2735
- getConfig(): any;
2867
+ child(component: LogComponent, config?: Partial<ServerOptions["logging"]>): Logger;
2868
+ }
2869
+
2870
+ /**
2871
+ * File Upload Manager for XyPriss Server
2872
+ * Handles multer configuration and file upload middleware setup
2873
+ */
2874
+
2875
+ interface FileUploadConfig {
2876
+ /** Enable file upload handling */
2877
+ enabled?: boolean;
2878
+ /** Maximum file size in bytes */
2879
+ maxFileSize?: number;
2880
+ /** Maximum number of files per request */
2881
+ maxFiles?: number;
2882
+ /** Allowed MIME types */
2883
+ allowedMimeTypes?: string[];
2884
+ /** Allowed file extensions */
2885
+ allowedExtensions?: string[];
2886
+ /** Upload destination directory */
2887
+ destination?: string;
2888
+ /** Custom filename function */
2889
+ filename?: (req: any, file: any, callback: (error: Error | null, filename: string) => void) => void;
2890
+ /** Detailed limits configuration */
2891
+ limits?: {
2892
+ /** Max field name size in bytes */
2893
+ fieldNameSize?: number;
2894
+ /** Max field value size in bytes */
2895
+ fieldSize?: number;
2896
+ /** Max number of non-file fields */
2897
+ fields?: number;
2898
+ /** Max file size in bytes */
2899
+ fileSize?: number;
2900
+ /** Max number of file fields */
2901
+ files?: number;
2902
+ /** Max number of header key=>value pairs */
2903
+ headerPairs?: number;
2904
+ };
2905
+ /** Preserve full paths instead of just filenames */
2906
+ preservePath?: boolean;
2907
+ /** Custom file filter function */
2908
+ fileFilter?: (req: any, file: any, callback: (error: Error | null, acceptFile: boolean) => void) => void;
2909
+ /** Storage type */
2910
+ storage?: 'disk' | 'memory' | 'custom';
2911
+ /** Create parent directories if they don't exist */
2912
+ createParentPath?: boolean;
2913
+ /** Abort request on limit reached */
2914
+ abortOnLimit?: boolean;
2915
+ /** Response message when limit is reached */
2916
+ responseOnLimit?: string;
2917
+ /** Use temporary files for large uploads */
2918
+ useTempFiles?: boolean;
2919
+ /** Temporary file directory */
2920
+ tempFileDir?: string;
2921
+ /** Parse nested objects in multipart data */
2922
+ parseNested?: boolean;
2923
+ /** Enable debug logging */
2924
+ debug?: boolean;
2925
+ /** Custom multer options */
2926
+ multerOptions?: {
2927
+ dest?: string;
2928
+ storage?: any;
2929
+ limits?: {
2930
+ fieldNameSize?: number;
2931
+ fieldSize?: number;
2932
+ fields?: number;
2933
+ fileSize?: number;
2934
+ files?: number;
2935
+ headerPairs?: number;
2936
+ };
2937
+ preservePath?: boolean;
2938
+ fileFilter?: (req: any, file: any, callback: (error: Error | null, acceptFile: boolean) => void) => void;
2939
+ [key: string]: any;
2940
+ };
2736
2941
  }
2737
2942
 
2738
2943
  /**
@@ -2757,6 +2962,47 @@ interface XyPrissMiddlewareAPI {
2757
2962
 
2758
2963
  type RequestHandler = (req: XyPrisRequest, res: XyPrisResponse, next?: NextFunction) => void | Promise<void>;
2759
2964
 
2965
+ /**
2966
+ * Configuration for individual servers in multi-server mode
2967
+ *
2968
+ * @interface MultiServerConfig
2969
+ * @version 4.5.11
2970
+ * @author XyPrissJS Team
2971
+ * @since 2025-01-06
2972
+ */
2973
+ interface MultiServerConfig {
2974
+ /** Unique identifier for this server instance */
2975
+ id: string;
2976
+ /** Port number for this server */
2977
+ port: number;
2978
+ /** Host for this server (optional, defaults to main config) */
2979
+ host?: string;
2980
+ /** Route prefix that this server should handle */
2981
+ routePrefix?: string;
2982
+ /** Array of allowed route patterns for this server */
2983
+ allowedRoutes?: string[];
2984
+ /** Server-specific overrides */
2985
+ server?: {
2986
+ host?: string;
2987
+ trustProxy?: boolean;
2988
+ jsonLimit?: string;
2989
+ urlEncodedLimit?: string;
2990
+ enableMiddleware?: boolean;
2991
+ autoParseJson?: boolean;
2992
+ };
2993
+ /** Security overrides for this server */
2994
+ security?: SecurityConfig;
2995
+ /** Performance overrides for this server */
2996
+ performance?: PerformanceConfig;
2997
+ /** Cache overrides for this server */
2998
+ cache?: CacheConfig;
2999
+ /** File upload overrides for this server */
3000
+ fileUpload?: FileUploadConfig;
3001
+ /** Middleware configuration specific to this server */
3002
+ middleware?: MiddlewareConfiguration;
3003
+ /** Logging configuration specific to this server */
3004
+ logging?: ComponentLogConfig;
3005
+ }
2760
3006
  /**
2761
3007
  * @fileoverview Comprehensive server options interface for XyPrissJS Express integration
2762
3008
  *
@@ -2996,6 +3242,45 @@ interface ServerOptions {
2996
3242
  onPortSwitch?: (originalPort: number, newPort: number) => void;
2997
3243
  };
2998
3244
  };
3245
+ /**
3246
+ * Multi-server configuration for creating multiple server instances
3247
+ *
3248
+ * Allows running multiple server instances with different configurations,
3249
+ * ports, and route scopes from a single configuration.
3250
+ *
3251
+ * @example
3252
+ * ```typescript
3253
+ * multiServer: {
3254
+ * enabled: true,
3255
+ * servers: [
3256
+ * {
3257
+ * id: "api-server",
3258
+ * port: 3001,
3259
+ * routePrefix: "/api/v1",
3260
+ * allowedRoutes: ["/api/v1/*"],
3261
+ * server: {
3262
+ * host: "localhost"
3263
+ * }
3264
+ * },
3265
+ * {
3266
+ * id: "admin-server",
3267
+ * port: 3002,
3268
+ * routePrefix: "/admin",
3269
+ * allowedRoutes: ["/admin/*"],
3270
+ * security: {
3271
+ * level: "maximum"
3272
+ * }
3273
+ * }
3274
+ * ]
3275
+ * }
3276
+ * ```
3277
+ */
3278
+ multiServer?: {
3279
+ /** Enable multi-server mode */
3280
+ enabled?: boolean;
3281
+ /** Array of server configurations */
3282
+ servers?: MultiServerConfig[];
3283
+ };
2999
3284
  /**
3000
3285
  * Request management configuration for handling timeouts, network quality, and request lifecycle
3001
3286
  *
@@ -3116,6 +3401,49 @@ interface ServerOptions {
3116
3401
  customValidator?: (req: any) => boolean | Promise<boolean>;
3117
3402
  };
3118
3403
  };
3404
+ /**
3405
+ * File upload configuration for handling multipart/form-data requests.
3406
+ *
3407
+ * Comprehensive file upload settings including size limits, allowed types,
3408
+ * storage options, and security features for file handling.
3409
+ *
3410
+ * @example
3411
+ * ```typescript
3412
+ * fileUpload: {
3413
+ * enabled: true,
3414
+ * maxFileSize: 10 * 1024 * 1024, // 10MB
3415
+ * maxFiles: 5,
3416
+ * allowedMimeTypes: ['image/jpeg', 'image/png', 'application/pdf'],
3417
+ * allowedExtensions: ['.jpg', '.jpeg', '.png', '.pdf'],
3418
+ * destination: './uploads',
3419
+ * filename: (req, file, callback) => {
3420
+ * callback(null, `${Date.now()}-${file.originalname}`);
3421
+ * },
3422
+ * limits: {
3423
+ * fieldNameSize: 100,
3424
+ * fieldSize: 1024,
3425
+ * fields: 10,
3426
+ * fileSize: 10 * 1024 * 1024,
3427
+ * files: 5,
3428
+ * headerPairs: 2000
3429
+ * },
3430
+ * preservePath: false,
3431
+ * fileFilter: (req, file, callback) => {
3432
+ * // Custom file validation logic
3433
+ * callback(null, true);
3434
+ * },
3435
+ * storage: 'disk', // 'disk' | 'memory' | 'custom'
3436
+ * createParentPath: true,
3437
+ * abortOnLimit: false,
3438
+ * responseOnLimit: 'File too large',
3439
+ * useTempFiles: false,
3440
+ * tempFileDir: '/tmp',
3441
+ * parseNested: true,
3442
+ * debug: false
3443
+ * }
3444
+ * ```
3445
+ */
3446
+ fileUpload?: FileUploadConfig;
3119
3447
  /**
3120
3448
  * Security configuration for the server.
3121
3449
  *
@@ -4019,6 +4347,73 @@ interface UltraFastApp {
4019
4347
  * ```
4020
4348
  */
4021
4349
  middleware: () => XyPrissMiddlewareAPI;
4350
+ /**
4351
+ * Multer instance for file uploads (available when fileUpload.enabled is true)
4352
+ */
4353
+ upload?: any;
4354
+ /**
4355
+ * Create single file upload middleware
4356
+ *
4357
+ * @param fieldname - Name of the form field
4358
+ * @returns Multer middleware for single file upload
4359
+ *
4360
+ * @example
4361
+ * ```typescript
4362
+ * app.post('/upload', app.uploadSingle('file'), (req, res) => {
4363
+ * console.log(req.file);
4364
+ * res.send('File uploaded');
4365
+ * });
4366
+ * ```
4367
+ */
4368
+ uploadSingle: (fieldname: string) => any;
4369
+ /**
4370
+ * Create array file upload middleware
4371
+ *
4372
+ * @param fieldname - Name of the form field
4373
+ * @param maxCount - Maximum number of files (optional)
4374
+ * @returns Multer middleware for array file upload
4375
+ *
4376
+ * @example
4377
+ * ```typescript
4378
+ * app.post('/upload', app.uploadArray('files', 5), (req, res) => {
4379
+ * console.log(req.files);
4380
+ * res.send('Files uploaded');
4381
+ * });
4382
+ * ```
4383
+ */
4384
+ uploadArray?: (fieldname: string, maxCount?: number) => any;
4385
+ /**
4386
+ * Create fields file upload middleware
4387
+ *
4388
+ * @param fields - Array of field configurations
4389
+ * @returns Multer middleware for multiple fields upload
4390
+ *
4391
+ * @example
4392
+ * ```typescript
4393
+ * app.post('/upload', app.uploadFields([
4394
+ * { name: 'avatar', maxCount: 1 },
4395
+ * { name: 'gallery', maxCount: 8 }
4396
+ * ]), (req, res) => {
4397
+ * console.log(req.files);
4398
+ * res.send('Files uploaded');
4399
+ * });
4400
+ * ```
4401
+ */
4402
+ uploadFields?: (fields: any[]) => any;
4403
+ /**
4404
+ * Create any file upload middleware
4405
+ *
4406
+ * @returns Multer middleware that accepts any files
4407
+ *
4408
+ * @example
4409
+ * ```typescript
4410
+ * app.post('/upload', app.uploadAny(), (req, res) => {
4411
+ * console.log(req.files);
4412
+ * res.send('Files uploaded');
4413
+ * });
4414
+ * ```
4415
+ */
4416
+ uploadAny?: () => any;
4022
4417
  /**
4023
4418
  * Scale up the cluster by adding workers.
4024
4419
  *
@@ -4502,133 +4897,6 @@ declare class ClusterManager extends EventEmitter implements RobustClusterManage
4502
4897
  private closePersistenceManager;
4503
4898
  }
4504
4899
 
4505
- /**
4506
- * Centralized Logger for FastApi.ts Server
4507
- * Provides granular control over logging output with enhanced robustness
4508
- */
4509
-
4510
- declare class Logger {
4511
- private config;
4512
- private static instance;
4513
- private buffer;
4514
- private flushTimer?;
4515
- private isDisposed;
4516
- private logQueue;
4517
- private isProcessingQueue;
4518
- private errorCount;
4519
- private lastErrorTime;
4520
- private suppressedComponents;
4521
- constructor(config?: ServerOptions["logging"]);
4522
- /**
4523
- * Initialize log buffer system
4524
- */
4525
- private initializeBuffer;
4526
- /**
4527
- * Setup error handling and recovery mechanisms
4528
- */
4529
- private setupErrorHandling;
4530
- /**
4531
- * Emergency logging that bypasses normal filtering
4532
- */
4533
- private emergencyLog;
4534
- /**
4535
- * Start auto-flush timer for buffered logging
4536
- */
4537
- private startAutoFlush;
4538
- /**
4539
- * Flush buffered log entries
4540
- */
4541
- flush(): void;
4542
- /**
4543
- * Get or create singleton instance
4544
- */
4545
- static getInstance(config?: ServerOptions["logging"]): Logger;
4546
- /**
4547
- * Deep merge two objects
4548
- */
4549
- private deepMerge;
4550
- /**
4551
- * Update logger configuration
4552
- */
4553
- updateConfig(config: ServerOptions["logging"]): void;
4554
- /**
4555
- * Get current logger configuration (for debugging)
4556
- */
4557
- getConfig(): ServerOptions["logging"];
4558
- /**
4559
- * Check if we should suppress this log due to error rate limiting
4560
- */
4561
- private shouldSuppressError;
4562
- /**
4563
- * Check if logging is enabled for a specific component and type
4564
- */
4565
- private shouldLog;
4566
- /**
4567
- * Get memory usage information
4568
- */
4569
- private getMemoryInfo;
4570
- /**
4571
- * Get process ID
4572
- */
4573
- private getProcessId;
4574
- /**
4575
- * Truncate message if it exceeds max line length
4576
- */
4577
- private truncateMessage;
4578
- /**
4579
- * Format log message
4580
- */
4581
- private formatMessage;
4582
- /**
4583
- * Write log entry to output
4584
- */
4585
- private writeLog;
4586
- /**
4587
- * Process log queue
4588
- */
4589
- private processLogQueue;
4590
- /**
4591
- * Log a message
4592
- */
4593
- private log;
4594
- error(component: LogComponent, message: string, ...args: any[]): void;
4595
- warn(component: LogComponent, message: string, ...args: any[]): void;
4596
- info(component: LogComponent, message: string, ...args: any[]): void;
4597
- debug(component: LogComponent, message: string, ...args: any[]): void;
4598
- verbose(component: LogComponent, message: string, ...args: any[]): void;
4599
- startup(component: LogComponent, message: string, ...args: any[]): void;
4600
- performance(component: LogComponent, message: string, ...args: any[]): void;
4601
- hotReload(component: LogComponent, message: string, ...args: any[]): void;
4602
- portSwitching(component: LogComponent, message: string, ...args: any[]): void;
4603
- securityWarning(message: string, ...args: any[]): void;
4604
- isEnabled(): boolean;
4605
- getLevel(): LogLevel;
4606
- isComponentEnabled(component: LogComponent): boolean;
4607
- isTypeEnabled(type: LogType): boolean;
4608
- /**
4609
- * Get logging statistics
4610
- */
4611
- getStats(): {
4612
- errorCount: number;
4613
- lastErrorTime: number;
4614
- suppressedComponents: string[];
4615
- bufferSize: number;
4616
- queueSize: number;
4617
- };
4618
- /**
4619
- * Clear suppressed components
4620
- */
4621
- clearSuppression(): void;
4622
- /**
4623
- * Dispose logger and cleanup resources
4624
- */
4625
- dispose(): void;
4626
- /**
4627
- * Create a child logger with component-specific configuration
4628
- */
4629
- child(component: LogComponent, config?: Partial<ServerOptions["logging"]>): Logger;
4630
- }
4631
-
4632
4900
  /**
4633
4901
  * Ultra-Fast Plugin System Types
4634
4902
  *
@@ -5484,11 +5752,16 @@ declare class XyPrissServer {
5484
5752
  private fileWatcherManager;
5485
5753
  private consoleInterceptor;
5486
5754
  private workerPoolComponent;
5755
+ private fileUploadManager;
5487
5756
  private notFoundHandler;
5488
5757
  private serverPluginManager;
5489
5758
  private securityMiddleware?;
5490
5759
  private lifecycleManager;
5491
5760
  constructor(userOptions?: ServerOptions);
5761
+ /**
5762
+ * Initialize file upload methods synchronously for immediate availability
5763
+ */
5764
+ private initializeFileUploadMethodsSync;
5492
5765
  /**
5493
5766
  * Initialize the ServerLifecycleManager
5494
5767
  */
@@ -5629,6 +5902,19 @@ declare class XyPrissServer {
5629
5902
  stop(): Promise<void>;
5630
5903
  }
5631
5904
 
5905
+ /**
5906
+ * Multi-Server Manager for XyPriss
5907
+ * Handles creation and management of multiple server instances
5908
+ */
5909
+
5910
+ interface MultiServerInstance {
5911
+ id: string;
5912
+ server: XyPrissServer;
5913
+ config: MultiServerConfig;
5914
+ port: number;
5915
+ host: string;
5916
+ }
5917
+
5632
5918
  /**
5633
5919
  * Safe JSON Middleware for Express
5634
5920
  * Automatically handles circular references in JSON responses
@@ -5728,8 +6014,9 @@ declare const expressStringify: (obj: any) => string;
5728
6014
  /**
5729
6015
  * Create ultra-fast Express server (zero-async)
5730
6016
  * Returns app instance ready to use immediately
6017
+ * If multi-server mode is enabled, returns a MultiServerApp interface
5731
6018
  */
5732
- declare function createServer(options?: ServerOptions): UltraFastApp;
6019
+ declare function createServer(options?: ServerOptions): UltraFastApp | MultiServerApp;
5733
6020
  /**
5734
6021
  * Create ultra-fast Express server class instance
5735
6022
  */
@@ -5739,6 +6026,41 @@ declare function createServerInstance(options?: ServerOptions): XyPrissServer;
5739
6026
  */
5740
6027
  declare function createCacheMiddleware(cache: SecureCacheAdapter, options?: RouteOptions): RequestHandler;
5741
6028
 
6029
+ /**
6030
+ * Multi-Server App interface for managing multiple server instances
6031
+ * Extends UltraFastApp to maintain API compatibility
6032
+ */
6033
+ interface MultiServerApp extends Omit<UltraFastApp, 'start'> {
6034
+ /**
6035
+ * Start all server instances (simple API - hides complexity)
6036
+ */
6037
+ start(): Promise<void>;
6038
+ /**
6039
+ * Start all servers (alias for start - more explicit)
6040
+ */
6041
+ startAllServers(): Promise<void>;
6042
+ /**
6043
+ * Stop all server instances
6044
+ */
6045
+ stop(): Promise<void>;
6046
+ /**
6047
+ * Stop all servers (alias for stop - more explicit)
6048
+ */
6049
+ stopAllServers(): Promise<void>;
6050
+ /**
6051
+ * Get all server instances
6052
+ */
6053
+ getServers(): MultiServerInstance[];
6054
+ /**
6055
+ * Get a specific server instance by ID
6056
+ */
6057
+ getServer(id: string): MultiServerInstance | undefined;
6058
+ /**
6059
+ * Get multi-server statistics
6060
+ */
6061
+ getStats(): any;
6062
+ }
6063
+
5742
6064
  /**
5743
6065
  * XyPrissJS Smart Routes
5744
6066
  * Intelligent route handlers with automatic optimization, caching, and security
@@ -10430,7 +10752,7 @@ declare class PluginDevelopmentHelpers {
10430
10752
  /**
10431
10753
  * Quick development server with sensible defaults
10432
10754
  */
10433
- declare function quickServer(port?: number): UltraFastApp;
10755
+ declare function quickServer(port?: number): UltraFastApp | MultiServerApp;
10434
10756
 
10435
10757
  /***************************************************************************
10436
10758
  * XyPrissJS - Advanced JavaScript Security Library
@@ -10465,4 +10787,4 @@ declare function quickServer(port?: number): UltraFastApp;
10465
10787
  declare function Router(): XyPrissRouter;
10466
10788
 
10467
10789
  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 };
10468
- 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, 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 };
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 };