@stacksjs/bun-router 0.0.2 → 0.0.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.
Files changed (128) hide show
  1. package/dist/{chunk-r15a48wc.js → chunk-cjdekj87.js} +536 -98
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +2 -2
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.js +454 -119
  6. package/package.json +6 -8
  7. package/dist/auth.d.ts +0 -77
  8. package/dist/cache/lru-cache.d.ts +0 -88
  9. package/dist/cache/middleware-memoization.d.ts +0 -101
  10. package/dist/cache/route-cache-warmer.d.ts +0 -125
  11. package/dist/cache/sqlite-cache.d.ts +0 -114
  12. package/dist/cache/streaming-cache.d.ts +0 -86
  13. package/dist/cli/colors.d.ts +0 -12
  14. package/dist/cli/index.d.ts +0 -10
  15. package/dist/cli/middleware.d.ts +0 -31
  16. package/dist/cli/openapi.d.ts +0 -17
  17. package/dist/cli/router.d.ts +0 -15
  18. package/dist/cli/routes.d.ts +0 -30
  19. package/dist/cli/utils.d.ts +0 -68
  20. package/dist/config.d.ts +0 -274
  21. package/dist/container/container.d.ts +0 -141
  22. package/dist/container/contextual-binding.d.ts +0 -112
  23. package/dist/container/decorators.d.ts +0 -114
  24. package/dist/container/service-provider.d.ts +0 -221
  25. package/dist/development/hot-reload.d.ts +0 -129
  26. package/dist/development/index.d.ts +0 -144
  27. package/dist/development/performance-profiler.d.ts +0 -152
  28. package/dist/development/route-debugger.d.ts +0 -102
  29. package/dist/development/route-inspector.d.ts +0 -142
  30. package/dist/development/typescript-utilities.d.ts +0 -116
  31. package/dist/docs.d.ts +0 -10
  32. package/dist/errors/circuit-breaker.d.ts +0 -138
  33. package/dist/errors/error-handler.d.ts +0 -57
  34. package/dist/errors/error-reporting.d.ts +0 -135
  35. package/dist/errors/exceptions.d.ts +0 -178
  36. package/dist/errors/graceful-degradation.d.ts +0 -130
  37. package/dist/errors/index.d.ts +0 -6
  38. package/dist/errors/router-errors.d.ts +0 -97
  39. package/dist/file-serving/static-files.d.ts +0 -98
  40. package/dist/middleware/auth.d.ts +0 -34
  41. package/dist/middleware/content_security_policy.d.ts +0 -54
  42. package/dist/middleware/cors.d.ts +0 -5
  43. package/dist/middleware/csrf.d.ts +0 -7
  44. package/dist/middleware/ddos_protection.d.ts +0 -47
  45. package/dist/middleware/file_security.d.ts +0 -23
  46. package/dist/middleware/file_upload.d.ts +0 -41
  47. package/dist/middleware/helmet.d.ts +0 -54
  48. package/dist/middleware/index.d.ts +0 -55
  49. package/dist/middleware/input_validation.d.ts +0 -46
  50. package/dist/middleware/json_body.d.ts +0 -4
  51. package/dist/middleware/performance_alerting.d.ts +0 -88
  52. package/dist/middleware/performance_dashboard.d.ts +0 -97
  53. package/dist/middleware/performance_monitor.d.ts +0 -236
  54. package/dist/middleware/pipeline.d.ts +0 -90
  55. package/dist/middleware/rate_limit.d.ts +0 -33
  56. package/dist/middleware/request_id.d.ts +0 -4
  57. package/dist/middleware/request_signing.d.ts +0 -96
  58. package/dist/middleware/request_tracer.d.ts +0 -76
  59. package/dist/middleware/response_cache.d.ts +0 -90
  60. package/dist/middleware/security.d.ts +0 -70
  61. package/dist/middleware/security_suite.d.ts +0 -46
  62. package/dist/middleware/session.d.ts +0 -7
  63. package/dist/model-binding/index.d.ts +0 -17
  64. package/dist/model-binding/model-middleware.d.ts +0 -80
  65. package/dist/model-binding/model-registry.d.ts +0 -125
  66. package/dist/model-binding.d.ts +0 -123
  67. package/dist/model-resolver-factory.d.ts +0 -31
  68. package/dist/observability/correlation.d.ts +0 -131
  69. package/dist/observability/health-checks.d.ts +0 -129
  70. package/dist/observability/index.d.ts +0 -92
  71. package/dist/observability/integration.d.ts +0 -112
  72. package/dist/observability/metrics.d.ts +0 -135
  73. package/dist/observability/tracing.d.ts +0 -112
  74. package/dist/optimization/bun-utilities.d.ts +0 -106
  75. package/dist/query-builder-integration.d.ts +0 -24
  76. package/dist/request/enhanced-request.d.ts +0 -143
  77. package/dist/request/macros.d.ts +0 -267
  78. package/dist/response/macros.d.ts +0 -207
  79. package/dist/response/response-factory.d.ts +0 -93
  80. package/dist/router/file-based-routing.d.ts +0 -40
  81. package/dist/router/file-streaming.d.ts +0 -6
  82. package/dist/router/fluent-router.d.ts +0 -179
  83. package/dist/router/fluent-routing.d.ts +0 -198
  84. package/dist/router/group-organization.d.ts +0 -5
  85. package/dist/router/handler-resolver.d.ts +0 -13
  86. package/dist/router/http-methods.d.ts +0 -10
  87. package/dist/router/index.d.ts +0 -114
  88. package/dist/router/middleware-integration.d.ts +0 -86
  89. package/dist/router/middleware.d.ts +0 -5
  90. package/dist/router/model-binding.d.ts +0 -7
  91. package/dist/router/optimized-route-matching.d.ts +0 -6
  92. package/dist/router/route-building.d.ts +0 -5
  93. package/dist/router/route-compiler.d.ts +0 -67
  94. package/dist/router/route-matching.d.ts +0 -5
  95. package/dist/router/route-trie.d.ts +0 -69
  96. package/dist/router/router.d.ts +0 -133
  97. package/dist/router/server.d.ts +0 -5
  98. package/dist/router/validation-integration.d.ts +0 -116
  99. package/dist/router/view-rendering.d.ts +0 -5
  100. package/dist/router/websocket.d.ts +0 -5
  101. package/dist/routing/route-caching.d.ts +0 -105
  102. package/dist/routing/route-throttling.d.ts +0 -112
  103. package/dist/routing/subdomain-routing.d.ts +0 -159
  104. package/dist/streaming/index.d.ts +0 -15
  105. package/dist/streaming/sse-handler.d.ts +0 -81
  106. package/dist/streaming/stream-handler.d.ts +0 -81
  107. package/dist/testing/auth-testing.d.ts +0 -107
  108. package/dist/testing/file-upload-testing.d.ts +0 -139
  109. package/dist/testing/index.d.ts +0 -10
  110. package/dist/testing/middleware-testing.d.ts +0 -99
  111. package/dist/testing/model-binding-testing.d.ts +0 -132
  112. package/dist/testing/performance-testing.d.ts +0 -202
  113. package/dist/testing/test-client.d.ts +0 -58
  114. package/dist/testing/test-request.d.ts +0 -43
  115. package/dist/testing/test-response.d.ts +0 -45
  116. package/dist/testing/types.d.ts +0 -206
  117. package/dist/testing/websocket-testing.d.ts +0 -170
  118. package/dist/types/controller-types.d.ts +0 -303
  119. package/dist/types/core.d.ts +0 -526
  120. package/dist/types/middleware-types.d.ts +0 -315
  121. package/dist/types/request-response-augmentation.d.ts +0 -373
  122. package/dist/types/route-inference.d.ts +0 -287
  123. package/dist/types.d.ts +0 -1620
  124. package/dist/utils/index.d.ts +0 -1
  125. package/dist/utils/query-preservation.d.ts +0 -31
  126. package/dist/utils.d.ts +0 -69
  127. package/dist/validation/validator.d.ts +0 -169
  128. package/dist/websocket/clustering.d.ts +0 -114
@@ -1,98 +0,0 @@
1
- /**
2
- * Static file middleware factory
3
- */
4
- export declare function createStaticFileMiddleware(config: StaticFileConfig): void;
5
- /**
6
- * Static file serving helpers
7
- */
8
- export declare const StaticFileHelpers: {
9
- /**
10
- * Create development server with hot reload
11
- */
12
- createDevelopmentServer: (config: StaticFileConfig) => any;
13
- /**
14
- * Create production server with aggressive caching
15
- */
16
- createProductionServer: (config: StaticFileConfig) => any;
17
- /**
18
- * Create SPA server with fallback to index.html
19
- */
20
- createSPAServer: (config: StaticFileConfig) => any
21
- };
22
- /**
23
- * File serving utilities
24
- */
25
- export declare const FileServingUtils: {
26
- /**
27
- * Calculate optimal cache settings based on file type
28
- */
29
- getOptimalCacheSettings: (filePath: string) => any;
30
- /**
31
- * Generate security headers for static files
32
- */
33
- generateSecurityHeaders: () => unknown;
34
- /**
35
- * Create file watcher for cache invalidation
36
- */
37
- createFileWatcher: (server: StaticFileServer, watchPath: string) => Promise<{ close: ()
38
- };
39
- /**
40
- * Static File Serving
41
- *
42
- * Efficient file serving using Bun.file() with advanced caching and optimization
43
- */
44
- export declare interface StaticFileConfig {
45
- root: string
46
- maxAge?: number
47
- immutable?: boolean
48
- etag?: boolean
49
- lastModified?: boolean
50
- index?: string[]
51
- extensions?: string[]
52
- fallthrough?: boolean
53
- setHeaders?: (res: Response, path: string, stat: any) => void
54
- compression?: boolean
55
- compressionThreshold?: number
56
- cacheControl?: string
57
- dotfiles?: 'allow' | 'deny' | 'ignore'
58
- }
59
- export declare interface FileCache {
60
- content: ArrayBuffer
61
- etag: string
62
- lastModified: string
63
- mimeType: string
64
- size: number
65
- compressed?: ArrayBuffer
66
- compressedEtag?: string
67
- }
68
- export declare interface FileStats {
69
- hits: number
70
- misses: number
71
- bytesServed: number
72
- compressionRatio: number
73
- averageResponseTime: number
74
- lastAccessed: number
75
- }
76
- /**
77
- * High-performance static file server using Bun.file()
78
- */
79
- export declare class StaticFileServer {
80
- private config: Required<StaticFileConfig>;
81
- private cache: any;
82
- private stats: any;
83
- private compressionCache: any;
84
- constructor(config: StaticFileConfig);
85
- serve(request: Request): Promise<Response | null>;
86
- serveFile(request: Request, filePath: string, requestPath: string): Promise<Response>;
87
- private serveCachedFile(request: Request, cached: FileCache, requestPath: string, startTime: number): Response;
88
- private resolveFile(pathname: string): Promise<string | null>;
89
- private joinPath(parts: string[]): string;
90
- private generateEtag(content: ArrayBuffer, lastModified: string): string;
91
- private compressContent(content: ArrayBuffer): Promise<ArrayBuffer | null>;
92
- private getMimeType(filePath: string): string;
93
- private updateStats(path: string, bytes: number, startTime: number, cached: boolean): void;
94
- getStats(): Record<string, FileStats>;
95
- clearCache(): void;
96
- getCacheSize(): number;
97
- preloadFiles(paths: string[]): Promise<void>;
98
- }
@@ -1,34 +0,0 @@
1
- import type { EnhancedRequest, Middleware, NextFunction } from '../types';
2
- /**
3
- * Extracts and decodes Basic Auth credentials from Authorization header
4
- */
5
- export declare function extractBasicAuth(authHeader: string): { username: string, password: string } | null;
6
- /**
7
- * Extracts Bearer token from Authorization header
8
- */
9
- export declare function extractBearerToken(authHeader: string): string | null;
10
- /**
11
- * Extracts API key from various sources
12
- */
13
- export declare function extractApiKey(req: EnhancedRequest, source?: 'header' | 'query' | 'cookie', key?: string): string | null;
14
- // Convenience factory functions for common auth types
15
- export declare function basicAuth(validator: (credentials: { username: string, password: string }, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
16
- export declare function bearerAuth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
17
- export declare function jwtAuth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
18
- export declare function apiKeyAuth(validator: (apiKey: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
19
- export declare function oauth2Auth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
20
- export declare interface AuthOptions {
21
- type: 'basic' | 'bearer' | 'api-key' | 'oauth2' | 'jwt' | 'custom'
22
- validator: (credentials: any, req: EnhancedRequest) => Promise<boolean> | boolean
23
- userExtractor?: (credentials: any, req: EnhancedRequest) => Promise<any> | any
24
- source?: 'header' | 'query' | 'cookie'
25
- key?: string
26
- realm?: string
27
- credentialsExtractor?: (req: EnhancedRequest) => Promise<any> | any
28
- attachUser?: boolean
29
- }
30
- export declare class AuthMiddleware implements Middleware {
31
- private options: AuthOptions;
32
- constructor(options: AuthOptions);
33
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
34
- }
@@ -1,54 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- // Factory function for easy use
3
- export declare function contentSecurityPolicy(options?: CSPOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
4
- export declare interface CSPDirectives {
5
- 'default-src'?: string[]
6
- 'script-src'?: string[]
7
- 'script-src-elem'?: string[]
8
- 'script-src-attr'?: string[]
9
- 'style-src'?: string[]
10
- 'style-src-elem'?: string[]
11
- 'style-src-attr'?: string[]
12
- 'img-src'?: string[]
13
- 'font-src'?: string[]
14
- 'connect-src'?: string[]
15
- 'media-src'?: string[]
16
- 'object-src'?: string[]
17
- 'child-src'?: string[]
18
- 'frame-src'?: string[]
19
- 'worker-src'?: string[]
20
- 'frame-ancestors'?: string[]
21
- 'form-action'?: string[]
22
- 'base-uri'?: string[]
23
- 'manifest-src'?: string[]
24
- 'prefetch-src'?: string[]
25
- 'navigate-to'?: string[]
26
- 'report-uri'?: string[]
27
- 'report-to'?: string[]
28
- 'require-trusted-types-for'?: string[]
29
- 'trusted-types'?: string[]
30
- 'upgrade-insecure-requests'?: boolean
31
- 'block-all-mixed-content'?: boolean
32
- 'plugin-types'?: string[]
33
- 'sandbox'?: string[]
34
- 'disown-opener'?: boolean
35
- }
36
- export declare interface CSPOptions {
37
- directives?: CSPDirectives
38
- reportOnly?: boolean
39
- reportUri?: string
40
- reportTo?: string
41
- useNonces?: boolean
42
- nonceLength?: number
43
- upgradeInsecureRequests?: boolean
44
- blockAllMixedContent?: boolean
45
- }
46
- export declare class ContentSecurityPolicy {
47
- private options: CSPOptions;
48
- private nonces: Map<string, string>;
49
- constructor(options?: CSPOptions);
50
- private generateNonce(): string;
51
- private buildCSPHeader(): string;
52
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
53
- getNonce(url: string): string | undefined;
54
- }
@@ -1,5 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- export declare class Cors {
3
- private getCorsHeaders(): Record<string, string>;
4
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
5
- }
@@ -1,7 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- export declare class Csrf {
3
- static private tokens: any;
4
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
5
- private generateToken(secret: string): string;
6
- private parseCookies(req: Request): Record<string, string>;
7
- }
@@ -1,47 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- // Factory function for easy use
3
- export declare function ddosProtection(options?: DDoSProtectionOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
4
- export declare interface DDoSProtectionOptions {
5
- enabled?: boolean
6
- maxRequestsPerSecond?: number
7
- maxRequestsPerMinute?: number
8
- maxRequestsPerHour?: number
9
- burstLimit?: number
10
- windowSize?: number
11
- blockDuration?: number
12
- whitelistedIPs?: string[]
13
- blacklistedIPs?: string[]
14
- trustProxy?: boolean
15
- skipSuccessfulRequests?: boolean
16
- skipFailedRequests?: boolean
17
- keyGenerator?: (req: EnhancedRequest) => string
18
- onLimitReached?: (req: EnhancedRequest, rateLimitInfo: any) => Response | Promise<Response>
19
- store?: 'memory' | 'redis'
20
- redis?: {
21
- url: string
22
- prefix?: string
23
- }
24
- }
25
- declare interface RequestInfo {
26
- count: number
27
- firstRequest: number
28
- lastRequest: number
29
- blocked: boolean
30
- blockExpires?: number
31
- }
32
- export declare class DDoSProtection {
33
- private options: DDoSProtectionOptions;
34
- private requestStore: Map<string, RequestInfo>;
35
- private cleanupInterval: Timer | null;
36
- constructor(options?: DDoSProtectionOptions);
37
- private defaultKeyGenerator(req: EnhancedRequest): string;
38
- private startCleanupInterval(): void;
39
- private isWhitelisted(ip: string): boolean;
40
- private isBlacklisted(ip: string): boolean;
41
- private getRateLimitInfo(key: string, now: number): RequestInfo;
42
- private shouldBlock(info: RequestInfo, now: number): boolean;
43
- private blockIP(info: RequestInfo, now: number): void;
44
- private createBlockedResponse(req: EnhancedRequest, info: RequestInfo): Response;
45
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
46
- destroy(): void;
47
- }
@@ -1,23 +0,0 @@
1
- import type { UploadedFile } from './file_upload';
2
- export declare function createFileSecurity(config?: FileSecurityConfig): FileSecurity;
3
- export declare interface FileSecurityConfig {
4
- scanForMalware?: boolean
5
- checkMagicNumbers?: boolean
6
- sanitizeFilenames?: boolean
7
- preventExecutableUploads?: boolean
8
- maxFilenameLength?: number
9
- }
10
- export declare class FileSecurity {
11
- private config: Required<FileSecurityConfig>;
12
- readonly private FILE_SIGNATURES: Record<string, Uint8Array[]>;
13
- readonly private EXECUTABLE_EXTENSIONS: any;
14
- constructor(config?: FileSecurityConfig);
15
- validateFile(file: UploadedFile): { isValid: boolean, errors: string[] };
16
- private validateFileSignature(file: UploadedFile): boolean;
17
- private sanitizeFilename(filename: string): string;
18
- private getFileExtension(filename: string): string;
19
- private basicMalwareScan(file: UploadedFile): boolean;
20
- getSafeFilename(originalName: string): string;
21
- isAllowedFileType(mimetype: string, allowedTypes: string[]): boolean;
22
- isWithinSizeLimit(fileSize: number, maxSize: number): boolean;
23
- }
@@ -1,41 +0,0 @@
1
- import FileSecurity from './file_security';
2
- import type { EnhancedRequest, NextFunction } from '../types';
3
- import type { FileSecurityConfig } from './file_security';
4
- // Factory function for easier usage
5
- export declare function fileUpload(config?: FileUploadConfig): FileUpload;
6
- // Specialized factory functions
7
- export declare function singleFileUpload(fieldName: string, config?: FileUploadConfig): FileUpload;
8
- export declare function multipleFileUpload(maxFiles?: number, config?: FileUploadConfig): FileUpload;
9
- export declare function imageUpload(config?: FileUploadConfig): FileUpload;
10
- export declare function documentUpload(config?: FileUploadConfig): FileUpload;
11
- export declare interface UploadedFile {
12
- fieldName: string
13
- originalName: string
14
- filename: string
15
- path: string
16
- size: number
17
- mimetype: string
18
- buffer: ArrayBuffer
19
- }
20
- export declare interface FileUploadConfig extends FileSecurityConfig {
21
- destination?: string
22
- maxFileSize?: number
23
- maxFiles?: number
24
- allowedMimeTypes?: string[]
25
- allowedExtensions?: string[]
26
- preserveOriginalName?: boolean
27
- generateUniqueFilename?: boolean
28
- createDestination?: boolean
29
- }
30
- export declare interface FileUploadOptions extends FileUploadConfig {
31
- fieldName?: string | string[]
32
- }
33
- export declare class FileUpload {
34
- private config: Required<FileUploadConfig>;
35
- private fileSecurity: FileSecurity;
36
- constructor(config?: FileUploadConfig);
37
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
38
- private generateFilename(originalName: string): string;
39
- private formatBytes(bytes: number): string;
40
- private createErrorResponse(message: string, status: number): Response;
41
- }
@@ -1,54 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- export declare interface HelmetOptions {
3
- contentSecurityPolicy?: boolean | {
4
- directives?: Record<string, string[]>
5
- reportOnly?: boolean
6
- reportUri?: string
7
- upgradeInsecureRequests?: boolean
8
- blockAllMixedContent?: boolean
9
- }
10
- crossOriginEmbedderPolicy?: boolean | {
11
- policy?: 'require-corp' | 'credentialless'
12
- }
13
- crossOriginOpenerPolicy?: boolean | {
14
- policy?: 'same-origin' | 'same-origin-allow-popups' | 'unsafe-none'
15
- }
16
- crossOriginResourcePolicy?: boolean | {
17
- policy?: 'same-site' | 'same-origin' | 'cross-origin'
18
- }
19
- dnsPrefetchControl?: boolean | {
20
- allow?: boolean
21
- }
22
- expectCt?: boolean | {
23
- enforce?: boolean
24
- maxAge?: number
25
- reportUri?: string
26
- }
27
- frameguard?: boolean | {
28
- action?: 'deny' | 'sameorigin'
29
- domain?: string
30
- }
31
- hidePoweredBy?: boolean
32
- hsts?: boolean | {
33
- maxAge?: number
34
- includeSubDomains?: boolean
35
- preload?: boolean
36
- }
37
- ieNoOpen?: boolean
38
- noSniff?: boolean
39
- originAgentCluster?: boolean
40
- permittedCrossDomainPolicies?: boolean | {
41
- permittedPolicies?: 'none' | 'master-only' | 'by-content-type' | 'all'
42
- }
43
- referrerPolicy?: boolean | {
44
- policy?: string | string[]
45
- }
46
- xssFilter?: boolean | {
47
- setOnOldIE?: boolean
48
- }
49
- }
50
- export declare class Helmet {
51
- private options: HelmetOptions;
52
- constructor(options?: HelmetOptions);
53
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
54
- }
@@ -1,55 +0,0 @@
1
- import Auth, { apiKeyAuth, basicAuth, bearerAuth, extractApiKey, extractBasicAuth, extractBearerToken, jwtAuth, oauth2Auth, } from './auth';
2
- import Cors from './cors';
3
- import Csrf from './csrf';
4
- import JsonBody from './json_body';
5
- import RequestId from './request_id';
6
- import RequestSigning from './request_signing';
7
- import Session from './session';
8
- export type { NonceStore, RequestSigningOptions, SignatureAlgorithm, SignedPart } from './request_signing';
9
- export declare function auth(): Auth;
10
- // Factory functions for easier middleware creation
11
- export declare const cors: () => Cors;
12
- export declare const jsonBody: () => JsonBody;
13
- export declare const requestId: () => RequestId;
14
- export declare const session: () => Session;
15
- export declare const csrf: () => Csrf;
16
- export declare const middleware: Proxy;
17
- export { default as Auth } from './auth';
18
- export { default as ContentSecurityPolicy } from './content_security_policy';
19
- export { contentSecurityPolicy } from './content_security_policy';
20
- export { default as Cors } from './cors';
21
- export { default as Csrf } from './csrf';
22
- export { default as DDoSProtection } from './ddos_protection';
23
- export { ddosProtection } from './ddos_protection';
24
- export { default as FileSecurity } from './file_security';
25
- export { default as FileUpload } from './file_upload';
26
- export { documentUpload, fileUpload, imageUpload, multipleFileUpload, singleFileUpload } from './file_upload';
27
- export { default as Helmet } from './helmet';
28
- export { default as InputValidation } from './input_validation';
29
- export { inputValidation } from './input_validation';
30
- export { default as JsonBody } from './json_body';
31
- export { default as PerformanceAlerting, performanceAlerting } from './performance_alerting';
32
- export { default as PerformanceDashboard, performanceDashboard } from './performance_dashboard';
33
- export { default as PerformanceMonitor, performanceMonitor } from './performance_monitor';
34
- export { default as RateLimit } from './rate_limit';
35
- export { rateLimit } from './rate_limit';
36
- export { default as RequestId } from './request_id';
37
- export { InMemoryNonceStore, default as RequestSigning, requestSigning, signRequest, verifySignature } from './request_signing';
38
- export { SignatureError } from './request_signing';
39
- export { default as RequestTracer, requestTracer } from './request_tracer';
40
- export { default as Security } from './security';
41
- export { security } from './security';
42
- export { default as SecuritySuite } from './security_suite';
43
- export { securitySuite } from './security_suite';
44
- export { default as Session } from './session';
45
- export {
46
- apiKeyAuth,
47
- basicAuth,
48
- bearerAuth,
49
- extractApiKey,
50
- extractBasicAuth,
51
- extractBearerToken,
52
- jwtAuth,
53
- oauth2Auth,
54
- };
55
- export default middleware;
@@ -1,46 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- // Factory function for easy use
3
- export declare function inputValidation(options?: InputValidationOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
4
- export declare interface ValidationRule {
5
- type: 'string' | 'number' | 'boolean' | 'email' | 'url' | 'uuid' | 'date' | 'regex' | 'custom'
6
- required?: boolean
7
- min?: number
8
- max?: number
9
- pattern?: RegExp
10
- enum?: unknown[]
11
- custom?: (value: unknown) => boolean | string
12
- sanitize?: boolean
13
- transform?: (value: unknown) => unknown
14
- }
15
- export declare interface ValidationSchema {
16
-
17
- }
18
- export declare interface InputValidationOptions {
19
- enabled?: boolean
20
- schemas?: {
21
- query?: ValidationSchema
22
- body?: ValidationSchema
23
- headers?: ValidationSchema
24
- params?: ValidationSchema
25
- }
26
- sanitizeByDefault?: boolean
27
- strictMode?: boolean
28
- allowUnknownFields?: boolean
29
- maxDepth?: number
30
- onValidationError?: (errors: ValidationError[]) => Response
31
- }
32
- export declare interface ValidationError {
33
- field: string
34
- message: string
35
- value: any
36
- rule: string
37
- }
38
- export declare class InputValidation {
39
- private options: InputValidationOptions;
40
- constructor(options?: InputValidationOptions);
41
- private validateValue(value: any, rule: ValidationRule, fieldPath: string): ValidationError[];
42
- private sanitizeValue(value: any, rule: ValidationRule): any;
43
- private validateObject(obj: any, schema: ValidationSchema, basePath?: any, depth?: any): ValidationError[];
44
- private parseRequestBody(req: EnhancedRequest): Promise<any>;
45
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
46
- }
@@ -1,4 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- export declare class JsonBody {
3
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
4
- }
@@ -1,88 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- import type { PerformanceMetrics } from './performance_monitor';
3
- // Factory function for easy use
4
- export declare function performanceAlerting(options?: AlertingOptions): PerformanceAlerting;
5
- export declare interface AlertRule {
6
- id: string
7
- name: string
8
- description?: string
9
- enabled: boolean
10
- metric: 'responseTime' | 'errorRate' | 'memoryUsage' | 'cpuUsage' | 'requestRate' | 'custom'
11
- condition: 'gt' | 'lt' | 'eq' | 'gte' | 'lte'
12
- threshold: number
13
- duration?: number
14
- severity: 'info' | 'warning' | 'critical'
15
- cooldown?: number
16
- customEvaluator?: (metrics: PerformanceMetrics[]) => boolean
17
- }
18
- export declare interface AlertNotification {
19
- id: string
20
- ruleId: string
21
- ruleName: string
22
- severity: 'info' | 'warning' | 'critical'
23
- message: string
24
- timestamp: number
25
- resolved: boolean
26
- resolvedAt?: number
27
- metadata: Record<string, any>
28
- }
29
- export declare interface AlertChannel {
30
- type: 'webhook' | 'slack' | 'email' | 'console' | 'custom'
31
- enabled: boolean
32
- config: {
33
- url?: string
34
- token?: string
35
- channel?: string
36
- email?: string
37
- customHandler?: (notification: AlertNotification) => Promise<void>
38
- }
39
- filters?: {
40
- severities?: Array<'info' | 'warning' | 'critical'>
41
- rules?: string[]
42
- }
43
- }
44
- export declare interface AlertingOptions {
45
- enabled?: boolean
46
- rules?: AlertRule[]
47
- channels?: AlertChannel[]
48
- defaultCooldown?: number
49
- maxAlerts?: number
50
- autoResolve?: boolean
51
- autoResolveTimeout?: number
52
- }
53
- export declare class PerformanceAlerting {
54
- private options: AlertingOptions;
55
- private rules: Map<string, AlertRule>;
56
- private channels: AlertChannel[];
57
- private notifications: AlertNotification[];
58
- private lastAlertTimes: Map<string, number>;
59
- private metricsBuffer: PerformanceMetrics[];
60
- private checkInterval?: Timer;
61
- constructor(options?: AlertingOptions);
62
- private addDefaultRules(): void;
63
- private startAlertingEngine(): void;
64
- private evaluateRules(): void;
65
- private extractMetricValues(metrics: PerformanceMetrics[], metricType: string): number[];
66
- private evaluateCondition(value: number, condition: string, threshold: number): boolean;
67
- private triggerAlert(rule: AlertRule, value: any, metrics: PerformanceMetrics[]): Promise<void>;
68
- private formatAlertMessage(rule: AlertRule, value: any, metrics: PerformanceMetrics[]): string;
69
- private sendNotification(channel: AlertChannel, notification: AlertNotification): Promise<void>;
70
- private sendConsoleNotification(notification: AlertNotification): void;
71
- private sendWebhookNotification(channel: AlertChannel, notification: AlertNotification): Promise<void>;
72
- private sendSlackNotification(channel: AlertChannel, notification: AlertNotification): Promise<void>;
73
- private sendEmailNotification(channel: AlertChannel, notification: AlertNotification): Promise<void>;
74
- private cleanupOldNotifications(): void;
75
- private autoResolveAlerts(): void;
76
- private generateId(): string;
77
- addMetrics(metrics: PerformanceMetrics): void;
78
- addRule(rule: AlertRule): void;
79
- removeRule(ruleId: string): void;
80
- updateRule(ruleId: string, updates: Partial<AlertRule>): void;
81
- addChannel(channel: AlertChannel): void;
82
- removeChannel(index: number): void;
83
- getActiveAlerts(): AlertNotification[];
84
- getAllNotifications(): AlertNotification[];
85
- resolveAlert(alertId: string): void;
86
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
87
- destroy(): void;
88
- }
@@ -1,97 +0,0 @@
1
- import type { EnhancedRequest, NextFunction } from '../types';
2
- import type { TraceSpan } from './request_tracer';
3
- // Factory function for easy use
4
- export declare function performanceDashboard(options?: DashboardOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response | null>;
5
- export declare interface DashboardOptions {
6
- enabled?: boolean
7
- path?: string
8
- title?: string
9
- refreshInterval?: number
10
- maxMetrics?: number
11
- authentication?: {
12
- enabled?: boolean
13
- username?: string
14
- password?: string
15
- apiKey?: string
16
- }
17
- features?: {
18
- realTimeMetrics?: boolean
19
- historicalCharts?: boolean
20
- alertsPanel?: boolean
21
- tracingView?: boolean
22
- systemMetrics?: boolean
23
- }
24
- }
25
- export declare interface DashboardData {
26
- metrics: {
27
- current: {
28
- totalRequests: number
29
- averageResponseTime: number
30
- errorRate: number
31
- requestsPerSecond: number
32
- memoryUsage: number
33
- cpuUsage: number
34
- }
35
- historical: Array<{
36
- timestamp: number
37
- responseTime: number
38
- memoryUsage: number
39
- requestCount: number
40
- errorCount: number
41
- }>
42
- distribution: {
43
- statusCodes: Record<number, number>
44
- paths: Record<string, number>
45
- methods: Record<string, number>
46
- responseTimes: Array<{ range: string, count: number }>
47
- }
48
- }
49
- alerts: Array<{
50
- id: string
51
- type: 'warning' | 'critical'
52
- message: string
53
- timestamp: number
54
- resolved: boolean
55
- }>
56
- traces: TraceSpan[]
57
- system: {
58
- uptime: number
59
- nodeVersion: string
60
- bunVersion: string
61
- platform: string
62
- arch: string
63
- memory: NodeJS.MemoryUsage
64
- cpu: NodeJS.CpuUsage
65
- }
66
- }
67
- export declare class PerformanceDashboard {
68
- private options: DashboardOptions;
69
- private metricsHistory: Array<{
70
- timestamp: number
71
- responseTime: number
72
- memoryUsage: number
73
- requestCount: number
74
- errorCount: number
75
- }>;
76
- private alerts: Array<{
77
- id: string
78
- type: 'warning' | 'critical'
79
- message: string
80
- timestamp: number
81
- resolved: boolean
82
- }>;
83
- private startTime: number;
84
- constructor(options?: DashboardOptions);
85
- private isAuthenticated(req: EnhancedRequest): boolean;
86
- private generateDashboardHTML(data: DashboardData): string;
87
- private getDashboardData(performanceMonitor?: any, requestTracer?: any): Promise<DashboardData>;
88
- handle(req: EnhancedRequest, next: NextFunction): Promise<Response | null>;
89
- addAlert(type: 'warning' | 'critical', message: string): void;
90
- resolveAlert(id: string): void;
91
- updateMetricsHistory(data: {
92
- responseTime: number
93
- memoryUsage: number
94
- requestCount: number
95
- errorCount: number
96
- }): void;
97
- }