@stacksjs/bun-router 0.0.2 → 0.0.4
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/{chunk-r15a48wc.js → chunk-cjdekj87.js} +536 -98
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +454 -119
- package/package.json +7 -9
- package/dist/auth.d.ts +0 -77
- package/dist/cache/lru-cache.d.ts +0 -88
- package/dist/cache/middleware-memoization.d.ts +0 -101
- package/dist/cache/route-cache-warmer.d.ts +0 -125
- package/dist/cache/sqlite-cache.d.ts +0 -114
- package/dist/cache/streaming-cache.d.ts +0 -86
- package/dist/cli/colors.d.ts +0 -12
- package/dist/cli/index.d.ts +0 -10
- package/dist/cli/middleware.d.ts +0 -31
- package/dist/cli/openapi.d.ts +0 -17
- package/dist/cli/router.d.ts +0 -15
- package/dist/cli/routes.d.ts +0 -30
- package/dist/cli/utils.d.ts +0 -68
- package/dist/config.d.ts +0 -274
- package/dist/container/container.d.ts +0 -141
- package/dist/container/contextual-binding.d.ts +0 -112
- package/dist/container/decorators.d.ts +0 -114
- package/dist/container/service-provider.d.ts +0 -221
- package/dist/development/hot-reload.d.ts +0 -129
- package/dist/development/index.d.ts +0 -144
- package/dist/development/performance-profiler.d.ts +0 -152
- package/dist/development/route-debugger.d.ts +0 -102
- package/dist/development/route-inspector.d.ts +0 -142
- package/dist/development/typescript-utilities.d.ts +0 -116
- package/dist/docs.d.ts +0 -10
- package/dist/errors/circuit-breaker.d.ts +0 -138
- package/dist/errors/error-handler.d.ts +0 -57
- package/dist/errors/error-reporting.d.ts +0 -135
- package/dist/errors/exceptions.d.ts +0 -178
- package/dist/errors/graceful-degradation.d.ts +0 -130
- package/dist/errors/index.d.ts +0 -6
- package/dist/errors/router-errors.d.ts +0 -97
- package/dist/file-serving/static-files.d.ts +0 -98
- package/dist/middleware/auth.d.ts +0 -34
- package/dist/middleware/content_security_policy.d.ts +0 -54
- package/dist/middleware/cors.d.ts +0 -5
- package/dist/middleware/csrf.d.ts +0 -7
- package/dist/middleware/ddos_protection.d.ts +0 -47
- package/dist/middleware/file_security.d.ts +0 -23
- package/dist/middleware/file_upload.d.ts +0 -41
- package/dist/middleware/helmet.d.ts +0 -54
- package/dist/middleware/index.d.ts +0 -55
- package/dist/middleware/input_validation.d.ts +0 -46
- package/dist/middleware/json_body.d.ts +0 -4
- package/dist/middleware/performance_alerting.d.ts +0 -88
- package/dist/middleware/performance_dashboard.d.ts +0 -97
- package/dist/middleware/performance_monitor.d.ts +0 -236
- package/dist/middleware/pipeline.d.ts +0 -90
- package/dist/middleware/rate_limit.d.ts +0 -33
- package/dist/middleware/request_id.d.ts +0 -4
- package/dist/middleware/request_signing.d.ts +0 -96
- package/dist/middleware/request_tracer.d.ts +0 -76
- package/dist/middleware/response_cache.d.ts +0 -90
- package/dist/middleware/security.d.ts +0 -70
- package/dist/middleware/security_suite.d.ts +0 -46
- package/dist/middleware/session.d.ts +0 -7
- package/dist/model-binding/index.d.ts +0 -17
- package/dist/model-binding/model-middleware.d.ts +0 -80
- package/dist/model-binding/model-registry.d.ts +0 -125
- package/dist/model-binding.d.ts +0 -123
- package/dist/model-resolver-factory.d.ts +0 -31
- package/dist/observability/correlation.d.ts +0 -131
- package/dist/observability/health-checks.d.ts +0 -129
- package/dist/observability/index.d.ts +0 -92
- package/dist/observability/integration.d.ts +0 -112
- package/dist/observability/metrics.d.ts +0 -135
- package/dist/observability/tracing.d.ts +0 -112
- package/dist/optimization/bun-utilities.d.ts +0 -106
- package/dist/query-builder-integration.d.ts +0 -24
- package/dist/request/enhanced-request.d.ts +0 -143
- package/dist/request/macros.d.ts +0 -267
- package/dist/response/macros.d.ts +0 -207
- package/dist/response/response-factory.d.ts +0 -93
- package/dist/router/file-based-routing.d.ts +0 -40
- package/dist/router/file-streaming.d.ts +0 -6
- package/dist/router/fluent-router.d.ts +0 -179
- package/dist/router/fluent-routing.d.ts +0 -198
- package/dist/router/group-organization.d.ts +0 -5
- package/dist/router/handler-resolver.d.ts +0 -13
- package/dist/router/http-methods.d.ts +0 -10
- package/dist/router/index.d.ts +0 -114
- package/dist/router/middleware-integration.d.ts +0 -86
- package/dist/router/middleware.d.ts +0 -5
- package/dist/router/model-binding.d.ts +0 -7
- package/dist/router/optimized-route-matching.d.ts +0 -6
- package/dist/router/route-building.d.ts +0 -5
- package/dist/router/route-compiler.d.ts +0 -67
- package/dist/router/route-matching.d.ts +0 -5
- package/dist/router/route-trie.d.ts +0 -69
- package/dist/router/router.d.ts +0 -133
- package/dist/router/server.d.ts +0 -5
- package/dist/router/validation-integration.d.ts +0 -116
- package/dist/router/view-rendering.d.ts +0 -5
- package/dist/router/websocket.d.ts +0 -5
- package/dist/routing/route-caching.d.ts +0 -105
- package/dist/routing/route-throttling.d.ts +0 -112
- package/dist/routing/subdomain-routing.d.ts +0 -159
- package/dist/streaming/index.d.ts +0 -15
- package/dist/streaming/sse-handler.d.ts +0 -81
- package/dist/streaming/stream-handler.d.ts +0 -81
- package/dist/testing/auth-testing.d.ts +0 -107
- package/dist/testing/file-upload-testing.d.ts +0 -139
- package/dist/testing/index.d.ts +0 -10
- package/dist/testing/middleware-testing.d.ts +0 -99
- package/dist/testing/model-binding-testing.d.ts +0 -132
- package/dist/testing/performance-testing.d.ts +0 -202
- package/dist/testing/test-client.d.ts +0 -58
- package/dist/testing/test-request.d.ts +0 -43
- package/dist/testing/test-response.d.ts +0 -45
- package/dist/testing/types.d.ts +0 -206
- package/dist/testing/websocket-testing.d.ts +0 -170
- package/dist/types/controller-types.d.ts +0 -303
- package/dist/types/core.d.ts +0 -526
- package/dist/types/middleware-types.d.ts +0 -315
- package/dist/types/request-response-augmentation.d.ts +0 -373
- package/dist/types/route-inference.d.ts +0 -287
- package/dist/types.d.ts +0 -1620
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/query-preservation.d.ts +0 -31
- package/dist/utils.d.ts +0 -69
- package/dist/validation/validator.d.ts +0 -169
- package/dist/websocket/clustering.d.ts +0 -114
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/bun-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "A",
|
|
4
|
+
"version": "0.0.4",
|
|
5
|
+
"description": "A fast, type-safe router for Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/stacksjs/bun-router#readme",
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
],
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
+
"bun": "./src/index.ts",
|
|
27
28
|
"types": "./dist/index.d.ts",
|
|
28
29
|
"import": "./dist/index.js"
|
|
29
30
|
},
|
|
30
31
|
"./*": {
|
|
32
|
+
"bun": "./src/*",
|
|
31
33
|
"import": "./dist/*"
|
|
32
34
|
}
|
|
33
35
|
},
|
|
@@ -64,18 +66,14 @@
|
|
|
64
66
|
"prepublishOnly": "bun --bun run build && bun run compile:all && bun run zip",
|
|
65
67
|
"release": "bun run changelog && bunx bumpp package.json --all",
|
|
66
68
|
"test": "bun test",
|
|
67
|
-
"dev:docs": "bun --bun vitepress dev docs",
|
|
68
|
-
"build:docs": "bun --bun vitepress build docs",
|
|
69
|
-
"preview:docs": "bun --bun vitepress preview docs",
|
|
70
69
|
"typecheck": "bunx --bun tsc --noEmit"
|
|
71
70
|
},
|
|
72
71
|
"dependencies": {
|
|
73
72
|
"@stacksjs/clapp": "^0.2.0",
|
|
74
|
-
"bun-query-builder": "^0.1.
|
|
75
|
-
"
|
|
76
|
-
"ts-rate-limiter": "^0.4.0"
|
|
73
|
+
"bun-query-builder": "^0.1.13",
|
|
74
|
+
"ts-rate-limiter": "^0.4.1"
|
|
77
75
|
},
|
|
78
76
|
"lint-staged": {
|
|
79
|
-
"*.{js,ts}": "bunx --bun
|
|
77
|
+
"*.{js,ts}": "bunx --bun pickier . --fix"
|
|
80
78
|
}
|
|
81
79
|
}
|
package/dist/auth.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, JwtPayload } from './types';
|
|
2
|
-
export type { JwtPayload };
|
|
3
|
-
// Types
|
|
4
|
-
export declare interface JwtVerifyOptions {
|
|
5
|
-
issuer?: string
|
|
6
|
-
audience?: string
|
|
7
|
-
subject?: string
|
|
8
|
-
algorithms?: string[]
|
|
9
|
-
expiresIn?: string | number
|
|
10
|
-
notBefore?: string | number
|
|
11
|
-
ignoreExpiration?: boolean
|
|
12
|
-
allowInvalidAsymmetricKeyTypes?: boolean
|
|
13
|
-
}
|
|
14
|
-
export declare interface JwtSignOptions {
|
|
15
|
-
algorithm?: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512' | 'PS256' | 'PS384' | 'PS512' | 'none'
|
|
16
|
-
expiresIn?: string | number
|
|
17
|
-
notBefore?: string | number
|
|
18
|
-
audience?: string | string[]
|
|
19
|
-
issuer?: string
|
|
20
|
-
subject?: string
|
|
21
|
-
keyid?: string
|
|
22
|
-
jwtid?: string
|
|
23
|
-
noTimestamp?: boolean
|
|
24
|
-
header?: Record<string, any>
|
|
25
|
-
encoding?: string
|
|
26
|
-
}
|
|
27
|
-
export declare interface ApiKeyOptions {
|
|
28
|
-
source?: 'header' | 'query' | 'cookie'
|
|
29
|
-
keyName?: string
|
|
30
|
-
keyPrefix?: string
|
|
31
|
-
}
|
|
32
|
-
export declare interface OAuth2Config {
|
|
33
|
-
clientId: string
|
|
34
|
-
clientSecret: string
|
|
35
|
-
authorizeUrl: string
|
|
36
|
-
tokenUrl: string
|
|
37
|
-
redirectUri: string
|
|
38
|
-
scope?: string
|
|
39
|
-
state?: string
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Simple JWT implementation for signing and verifying tokens
|
|
43
|
-
*/
|
|
44
|
-
export declare class JWT {
|
|
45
|
-
private secret: string;
|
|
46
|
-
constructor(secret: string);
|
|
47
|
-
sign(payload: Record<string, any>, options?: JwtSignOptions): string;
|
|
48
|
-
verify(token: string, options?: JwtVerifyOptions): Record<string, any> | null;
|
|
49
|
-
decode(token: string): { header: Record<string, any>, payload: Record<string, any> } | null;
|
|
50
|
-
private createSignature(data: string, secret: string, algorithm: string): string;
|
|
51
|
-
private parseTimespan(timespan: string): number;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* API Key manager to generate, validate and handle API keys
|
|
55
|
-
*/
|
|
56
|
-
export declare class ApiKeyManager {
|
|
57
|
-
private keys: Map<string, { owner: string, scopes: string[], expiresAt?: Date }>;
|
|
58
|
-
private options: ApiKeyOptions;
|
|
59
|
-
constructor(options?: ApiKeyOptions);
|
|
60
|
-
generateKey(owner: string, scopes?: string[], expiresIn?: number): string;
|
|
61
|
-
validateKey(key: string, requiredScopes?: string[]): boolean;
|
|
62
|
-
getKeyInfo(key: string): { owner: string, scopes: string[], expiresAt?: Date } | null;
|
|
63
|
-
revokeKey(key: string): boolean;
|
|
64
|
-
extractFromRequest(req: EnhancedRequest): string | null;
|
|
65
|
-
private randomString(length: number): string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* OAuth2 helper for authorization code flow
|
|
69
|
-
*/
|
|
70
|
-
export declare class OAuth2Helper {
|
|
71
|
-
private config: OAuth2Config;
|
|
72
|
-
constructor(config: OAuth2Config);
|
|
73
|
-
getAuthorizationUrl(additionalParams?: Record<string, string>): string;
|
|
74
|
-
exchangeCodeForToken(code: string): Promise<Record<string, any>>;
|
|
75
|
-
refreshToken(refreshToken: string): Promise<Record<string, any>>;
|
|
76
|
-
}
|
|
77
|
-
export default Auth;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Factory function to create LRU cache with common configurations
|
|
3
|
-
*/
|
|
4
|
-
export declare const createLRUCache: {
|
|
5
|
-
/**
|
|
6
|
-
* Create a small cache for frequently accessed items
|
|
7
|
-
*/
|
|
8
|
-
small: () => unknown;
|
|
9
|
-
/**
|
|
10
|
-
* Create a medium cache for general purpose use
|
|
11
|
-
*/
|
|
12
|
-
medium: () => unknown;
|
|
13
|
-
/**
|
|
14
|
-
* Create a large cache for heavy caching scenarios
|
|
15
|
-
*/
|
|
16
|
-
large: () => unknown;
|
|
17
|
-
/**
|
|
18
|
-
* Create a custom configured cache
|
|
19
|
-
*/
|
|
20
|
-
custom: () => unknown
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* High-performance LRU (Least Recently Used) cache implementation
|
|
24
|
-
* Optimized for Bun runtime with configurable size limits and TTL support
|
|
25
|
-
*/
|
|
26
|
-
export declare interface LRUCacheOptions {
|
|
27
|
-
maxSize: number
|
|
28
|
-
ttl?: number
|
|
29
|
-
onEvict?: (key: string, value: any) => void
|
|
30
|
-
allowStale?: boolean
|
|
31
|
-
updateAgeOnGet?: boolean
|
|
32
|
-
}
|
|
33
|
-
export declare interface CacheEntry<T = any> {
|
|
34
|
-
value: T
|
|
35
|
-
timestamp: number
|
|
36
|
-
accessCount: number
|
|
37
|
-
lastAccessed: number
|
|
38
|
-
ttl?: number
|
|
39
|
-
}
|
|
40
|
-
export declare interface CacheStats {
|
|
41
|
-
size: number
|
|
42
|
-
maxSize: number
|
|
43
|
-
hits: number
|
|
44
|
-
misses: number
|
|
45
|
-
evictions: number
|
|
46
|
-
hitRate: number
|
|
47
|
-
memoryUsage: number
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Node in the doubly linked list for LRU tracking
|
|
51
|
-
*/
|
|
52
|
-
declare class LRUNode<T = any> {
|
|
53
|
-
public key: string;
|
|
54
|
-
public entry: CacheEntry<T>;
|
|
55
|
-
public prev?: LRUNode<T> | null;
|
|
56
|
-
public next?: LRUNode<T> | null;
|
|
57
|
-
constructor(key: string, entry: CacheEntry<T>, prev?: LRUNode<T> | null, next?: LRUNode<T> | null);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* High-performance LRU cache with TTL support and detailed statistics
|
|
61
|
-
*/
|
|
62
|
-
export declare class LRUCache<T = any> {
|
|
63
|
-
private cache: any;
|
|
64
|
-
private head: LRUNode<T> | null;
|
|
65
|
-
private tail: LRUNode<T> | null;
|
|
66
|
-
private stats: any;
|
|
67
|
-
private options: LRUCacheOptions;
|
|
68
|
-
constructor(options: LRUCacheOptions);
|
|
69
|
-
get(key: string): T | undefined;
|
|
70
|
-
set(key: string, value: T, ttl?: number): void;
|
|
71
|
-
delete(key: string): boolean;
|
|
72
|
-
has(key: string): boolean;
|
|
73
|
-
clear(): void;
|
|
74
|
-
keys(): string[];
|
|
75
|
-
values(): T[];
|
|
76
|
-
getStats(): CacheStats;
|
|
77
|
-
resetStats(): void;
|
|
78
|
-
prune(): number;
|
|
79
|
-
getFrequentlyUsed(limit?: number): Array<{ key: string, value: T, accessCount: number }>;
|
|
80
|
-
resize(newMaxSize: number): void;
|
|
81
|
-
private isExpired(entry: CacheEntry<T>, now: number): boolean;
|
|
82
|
-
private moveToFront(node: LRUNode<T>): void;
|
|
83
|
-
private addToFront(node: LRUNode<T>): void;
|
|
84
|
-
private removeNode(node: LRUNode<T>): void;
|
|
85
|
-
private evictLRU(): void;
|
|
86
|
-
private estimateMemoryUsage(): number;
|
|
87
|
-
private estimateValueSize(value: any): number;
|
|
88
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { LRUCache } from './lru-cache';
|
|
2
|
-
import type { EnhancedRequest, MiddlewareHandler } from '../types';
|
|
3
|
-
import type { LRUCacheOptions } from './lru-cache';
|
|
4
|
-
/**
|
|
5
|
-
* Decorator for memoizing class methods
|
|
6
|
-
*/
|
|
7
|
-
export declare function Memoize(options?: {
|
|
8
|
-
memoizer: MiddlewareMemoizer
|
|
9
|
-
keyGenerator?: (...args: any[]) => string
|
|
10
|
-
ttl?: number
|
|
11
|
-
}): MethodDecorator;
|
|
12
|
-
/**
|
|
13
|
-
* Factory functions for creating memoizers
|
|
14
|
-
*/
|
|
15
|
-
export declare const createMemoizer: {
|
|
16
|
-
/**
|
|
17
|
-
* Create memoizer for development
|
|
18
|
-
*/
|
|
19
|
-
development: () => any;
|
|
20
|
-
/**
|
|
21
|
-
* Create memoizer for production
|
|
22
|
-
*/
|
|
23
|
-
production: () => any;
|
|
24
|
-
/**
|
|
25
|
-
* Create custom memoizer
|
|
26
|
-
*/
|
|
27
|
-
custom: (options: MemoizationOptions) => any
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Middleware result memoization for expensive operations
|
|
31
|
-
* Caches middleware results based on request characteristics
|
|
32
|
-
*/
|
|
33
|
-
export declare interface MemoizationOptions extends Omit<LRUCacheOptions, 'maxSize'> {
|
|
34
|
-
maxSize: number
|
|
35
|
-
keyGenerator?: (req: EnhancedRequest) => string
|
|
36
|
-
shouldMemoize?: (req: EnhancedRequest, result: any) => boolean
|
|
37
|
-
resultSerializer?: (result: any) => any
|
|
38
|
-
resultDeserializer?: (serialized: any) => any
|
|
39
|
-
}
|
|
40
|
-
export declare interface MemoizedResult<T = any> {
|
|
41
|
-
value: T
|
|
42
|
-
timestamp: number
|
|
43
|
-
requestFingerprint: string
|
|
44
|
-
executionTime: number
|
|
45
|
-
hitCount: number
|
|
46
|
-
}
|
|
47
|
-
export declare interface MemoizationStats {
|
|
48
|
-
totalRequests: number
|
|
49
|
-
cacheHits: number
|
|
50
|
-
cacheMisses: number
|
|
51
|
-
hitRate: number
|
|
52
|
-
averageExecutionTime: number
|
|
53
|
-
totalTimeSaved: number
|
|
54
|
-
memoryUsage: number
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Middleware memoization system for caching expensive operations
|
|
58
|
-
*/
|
|
59
|
-
export declare class MiddlewareMemoizer {
|
|
60
|
-
private cache: LRUCache<MemoizedResult>;
|
|
61
|
-
private stats: MemoizationStats;
|
|
62
|
-
private options: MemoizationOptions;
|
|
63
|
-
constructor(options: MemoizationOptions);
|
|
64
|
-
memoize<_T = any>(middleware: MiddlewareHandler, options?: {
|
|
65
|
-
name?: string
|
|
66
|
-
keyGenerator?: (req: EnhancedRequest) => string
|
|
67
|
-
shouldMemoize?: (req: EnhancedRequest, result: any) => boolean
|
|
68
|
-
ttl?: number
|
|
69
|
-
}): MiddlewareHandler;
|
|
70
|
-
memoizeFunction<TArgs extends any[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: {
|
|
71
|
-
name?: string
|
|
72
|
-
keyGenerator?: (...args: TArgs) => string
|
|
73
|
-
shouldMemoize?: (result: TResult, ...args: TArgs) => boolean
|
|
74
|
-
ttl?: number
|
|
75
|
-
}): (...args: TArgs) => Promise<TResult>;
|
|
76
|
-
invalidate(pattern: string | RegExp): number;
|
|
77
|
-
invalidateForUser(userId: string): number;
|
|
78
|
-
invalidateByTag(tag: string): number;
|
|
79
|
-
getPopularResults(limit?: number): Array<{
|
|
80
|
-
key: string
|
|
81
|
-
hitCount: number
|
|
82
|
-
executionTime: number
|
|
83
|
-
timeSaved: number
|
|
84
|
-
}>;
|
|
85
|
-
getStats(): MemoizationStats;
|
|
86
|
-
clear(): void;
|
|
87
|
-
prune(): number;
|
|
88
|
-
private generateCacheKey(req: EnhancedRequest, middlewareName: string, customKeyGenerator?: (req: EnhancedRequest) => string): string;
|
|
89
|
-
private generateRequestFingerprint(req: EnhancedRequest): string;
|
|
90
|
-
private updateHitRate(): void;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Common memoization patterns and utilities
|
|
94
|
-
*/
|
|
95
|
-
export declare class MemoizationPatterns {
|
|
96
|
-
static createDatabaseMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
97
|
-
static createApiMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
98
|
-
static createAuthMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
99
|
-
static createRateLimitMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
100
|
-
static createComputationMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
101
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type { LRUCache } from './lru-cache';
|
|
2
|
-
import type { StreamingCache } from './streaming-cache';
|
|
3
|
-
/**
|
|
4
|
-
* Factory functions for creating route cache warmers
|
|
5
|
-
*/
|
|
6
|
-
export declare const createRouteCacheWarmer: {
|
|
7
|
-
/**
|
|
8
|
-
* Create warmer for development environment
|
|
9
|
-
*/
|
|
10
|
-
development: (routeCache: LRUCache<any>, streamingCache?: StreamingCache) => any;
|
|
11
|
-
/**
|
|
12
|
-
* Create warmer for production environment
|
|
13
|
-
*/
|
|
14
|
-
production: (routeCache: LRUCache<any>, streamingCache?: StreamingCache) => any;
|
|
15
|
-
/**
|
|
16
|
-
* Create warmer with custom configuration
|
|
17
|
-
*/
|
|
18
|
-
custom: ( config: WarmupConfig, routeCache: LRUCache<any>, streamingCache?: StreamingCache, ) => any
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Route cache warming system for pre-populating caches with common routes
|
|
22
|
-
*/
|
|
23
|
-
export declare interface WarmupRoute {
|
|
24
|
-
path: string
|
|
25
|
-
method: string
|
|
26
|
-
priority: number
|
|
27
|
-
frequency: number
|
|
28
|
-
params?: Record<string, string>
|
|
29
|
-
query?: Record<string, string>
|
|
30
|
-
headers?: Record<string, string>
|
|
31
|
-
warmupData?: any
|
|
32
|
-
}
|
|
33
|
-
export declare interface AnalyticsRoute {
|
|
34
|
-
path: string
|
|
35
|
-
method: string
|
|
36
|
-
frequency: number
|
|
37
|
-
}
|
|
38
|
-
export declare interface RecentRoute {
|
|
39
|
-
path: string
|
|
40
|
-
method: string
|
|
41
|
-
timestamp: number
|
|
42
|
-
}
|
|
43
|
-
export declare interface PrecomputeRoute {
|
|
44
|
-
path: string
|
|
45
|
-
method: string
|
|
46
|
-
computeFunction: () => Promise<any>
|
|
47
|
-
cacheKey?: string
|
|
48
|
-
ttl?: number
|
|
49
|
-
}
|
|
50
|
-
export declare interface UserSegment {
|
|
51
|
-
segment: string
|
|
52
|
-
commonRoutes: string[]
|
|
53
|
-
priority: number
|
|
54
|
-
}
|
|
55
|
-
export declare interface TimeRange {
|
|
56
|
-
start: number
|
|
57
|
-
end: number
|
|
58
|
-
}
|
|
59
|
-
export declare interface TimeBasedPattern {
|
|
60
|
-
timeRange: TimeRange
|
|
61
|
-
routes: string[]
|
|
62
|
-
priority: number
|
|
63
|
-
}
|
|
64
|
-
export declare interface GeographicPattern {
|
|
65
|
-
region: string
|
|
66
|
-
routes: string[]
|
|
67
|
-
priority: number
|
|
68
|
-
}
|
|
69
|
-
export declare interface IntelligentWarmupPatterns {
|
|
70
|
-
userSegments?: UserSegment[]
|
|
71
|
-
timeBasedPatterns?: TimeBasedPattern[]
|
|
72
|
-
geographicPatterns?: GeographicPattern[]
|
|
73
|
-
}
|
|
74
|
-
export declare interface WarmupConfig {
|
|
75
|
-
enabled: boolean
|
|
76
|
-
maxConcurrency: number
|
|
77
|
-
warmupTimeout: number
|
|
78
|
-
retryAttempts: number
|
|
79
|
-
retryDelay: number
|
|
80
|
-
scheduleInterval?: number
|
|
81
|
-
priorityThreshold: number
|
|
82
|
-
}
|
|
83
|
-
export declare interface WarmupStats {
|
|
84
|
-
totalRoutes: number
|
|
85
|
-
successfulWarmups: number
|
|
86
|
-
failedWarmups: number
|
|
87
|
-
averageWarmupTime: number
|
|
88
|
-
lastWarmupTime: number
|
|
89
|
-
cacheHitRateImprovement: number
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Route cache warmer for pre-populating caches with frequently accessed routes
|
|
93
|
-
*/
|
|
94
|
-
export declare class RouteCacheWarmer {
|
|
95
|
-
private routes: WarmupRoute[];
|
|
96
|
-
private routeCache: LRUCache<any>;
|
|
97
|
-
private streamingCache?: StreamingCache;
|
|
98
|
-
private stats: WarmupStats;
|
|
99
|
-
private warmupTimer?: Timer;
|
|
100
|
-
private config: WarmupConfig;
|
|
101
|
-
constructor(config: WarmupConfig, routeCache: LRUCache<any>, streamingCache?: StreamingCache);
|
|
102
|
-
registerRoutes(routes: WarmupRoute[]): void;
|
|
103
|
-
registerRoute(route: WarmupRoute): void;
|
|
104
|
-
warmCache(options?: {
|
|
105
|
-
routes?: string[] // Specific routes to warm (by path)
|
|
106
|
-
maxRoutes?: number // Maximum number of routes to warm
|
|
107
|
-
skipLowPriority?: boolean
|
|
108
|
-
}): Promise<WarmupStats>;
|
|
109
|
-
warmFromAnalytics(analytics: {
|
|
110
|
-
topRoutes: AnalyticsRoute[]
|
|
111
|
-
recentRoutes: RecentRoute[]
|
|
112
|
-
}): Promise<void>;
|
|
113
|
-
precomputeRoutes(routes: PrecomputeRoute[]): Promise<number>;
|
|
114
|
-
intelligentWarmup(patterns: IntelligentWarmupPatterns): Promise<void>;
|
|
115
|
-
getStats(): WarmupStats;
|
|
116
|
-
resetStats(): void;
|
|
117
|
-
stop(): void;
|
|
118
|
-
private warmRoutesWithConcurrency(routes: WarmupRoute[]): Promise<{
|
|
119
|
-
successful: number
|
|
120
|
-
failed: number
|
|
121
|
-
}>;
|
|
122
|
-
private warmSingleRoute(route: WarmupRoute): Promise<void>;
|
|
123
|
-
private buildRouteUrl(route: WarmupRoute): string;
|
|
124
|
-
private schedulePeriodicWarmup(): void;
|
|
125
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Database } from 'bun:sqlite';
|
|
2
|
-
/**
|
|
3
|
-
* Cache middleware factory
|
|
4
|
-
*/
|
|
5
|
-
export declare function createSQLiteCacheMiddleware(cache: SQLiteCache, options?: {
|
|
6
|
-
keyGenerator?: (request: Request) => string
|
|
7
|
-
ttl?: number
|
|
8
|
-
skipMethods?: string[]
|
|
9
|
-
skipPaths?: string[]
|
|
10
|
-
skipHeaders?: string[]
|
|
11
|
-
}): void;
|
|
12
|
-
/**
|
|
13
|
-
* SQLite cache helpers
|
|
14
|
-
*/
|
|
15
|
-
export declare const SQLiteCacheHelpers: {
|
|
16
|
-
/**
|
|
17
|
-
* Create session cache
|
|
18
|
-
*/
|
|
19
|
-
createSessionCache: (cache: SQLiteCache) => unknown;
|
|
20
|
-
/**
|
|
21
|
-
* Create rate limiting cache
|
|
22
|
-
*/
|
|
23
|
-
createRateLimitCache: (cache: SQLiteCache) => unknown;
|
|
24
|
-
/**
|
|
25
|
-
* Create query result cache
|
|
26
|
-
*/
|
|
27
|
-
createQueryCache: (cache: SQLiteCache) => unknown
|
|
28
|
-
};
|
|
29
|
-
export declare interface SQLiteCacheConfig {
|
|
30
|
-
filename?: string
|
|
31
|
-
memory?: boolean
|
|
32
|
-
wal?: boolean
|
|
33
|
-
synchronous?: 'OFF' | 'NORMAL' | 'FULL'
|
|
34
|
-
journalMode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF'
|
|
35
|
-
cacheSize?: number
|
|
36
|
-
pageSize?: number
|
|
37
|
-
maxSize?: number
|
|
38
|
-
defaultTTL?: number
|
|
39
|
-
cleanupInterval?: number
|
|
40
|
-
compression?: boolean
|
|
41
|
-
}
|
|
42
|
-
export declare interface CacheEntry {
|
|
43
|
-
key: string
|
|
44
|
-
value: string
|
|
45
|
-
expires: number
|
|
46
|
-
created: number
|
|
47
|
-
accessed: number
|
|
48
|
-
hits: number
|
|
49
|
-
size: number
|
|
50
|
-
compressed: boolean
|
|
51
|
-
}
|
|
52
|
-
export declare interface CacheStats {
|
|
53
|
-
totalEntries: number
|
|
54
|
-
totalSize: number
|
|
55
|
-
hitRate: number
|
|
56
|
-
missRate: number
|
|
57
|
-
evictions: number
|
|
58
|
-
compressionRatio: number
|
|
59
|
-
averageAccessTime: number
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* High-performance SQLite-based cache
|
|
63
|
-
*/
|
|
64
|
-
export declare class SQLiteCache {
|
|
65
|
-
private db: Database;
|
|
66
|
-
private config: Required<SQLiteCacheConfig>;
|
|
67
|
-
private stats: CacheStats;
|
|
68
|
-
private cleanupTimer?: Timer;
|
|
69
|
-
private preparedStatements: {
|
|
70
|
-
get: any
|
|
71
|
-
set: any
|
|
72
|
-
delete: any
|
|
73
|
-
exists: any
|
|
74
|
-
clear: any
|
|
75
|
-
cleanup: any
|
|
76
|
-
stats: any
|
|
77
|
-
touch: any
|
|
78
|
-
};
|
|
79
|
-
constructor(config?: SQLiteCacheConfig);
|
|
80
|
-
get<T = any>(key: string): T | null;
|
|
81
|
-
set<T = any>(key: string, value: T, ttl?: number): boolean;
|
|
82
|
-
delete(key: string): boolean;
|
|
83
|
-
has(key: string): boolean;
|
|
84
|
-
clear(): boolean;
|
|
85
|
-
getStats(): CacheStats;
|
|
86
|
-
keys(pattern?: string): string[];
|
|
87
|
-
mget<T = any>(keys: string[]): Record<string, T | null>;
|
|
88
|
-
mset<T = any>(entries: Record<string, T>, ttl?: number): boolean;
|
|
89
|
-
increment(key: string, delta?: number, ttl?: number): number | null;
|
|
90
|
-
decrement(key: string, delta?: number, ttl?: number): number | null;
|
|
91
|
-
setnx<T = any>(key: string, value: T, ttl?: number): boolean;
|
|
92
|
-
getdel<T = any>(key: string): T | null;
|
|
93
|
-
expire(key: string, ttl: number): boolean;
|
|
94
|
-
ttl(key: string): number;
|
|
95
|
-
cleanup(): number;
|
|
96
|
-
close(): void;
|
|
97
|
-
private initializeDatabase(): void;
|
|
98
|
-
private prepareStatements(): void;
|
|
99
|
-
private startCleanupTimer(): void;
|
|
100
|
-
private evictIfNeeded(newEntrySize: number): void;
|
|
101
|
-
private updateCacheStats(): void;
|
|
102
|
-
private updateStats(operation: 'hit' | 'miss' | 'set', responseTime: number): void;
|
|
103
|
-
private compress(value: string): string | null;
|
|
104
|
-
private decompress(value: string): string;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* SQLite cache factory
|
|
108
|
-
*/
|
|
109
|
-
export declare class SQLiteCacheFactory {
|
|
110
|
-
static createMemoryCache(config?: Partial<SQLiteCacheConfig>): SQLiteCache;
|
|
111
|
-
static createPersistentCache(filename: string, config?: Partial<SQLiteCacheConfig>): SQLiteCache;
|
|
112
|
-
static createHighPerformanceCache(config?: Partial<SQLiteCacheConfig>): SQLiteCache;
|
|
113
|
-
static createDevelopmentCache(config?: Partial<SQLiteCacheConfig>): SQLiteCache;
|
|
114
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { LRUCache } from './lru-cache';
|
|
2
|
-
import type { LRUCacheOptions } from './lru-cache';
|
|
3
|
-
/**
|
|
4
|
-
* Factory functions for creating streaming caches with common configurations
|
|
5
|
-
*/
|
|
6
|
-
export declare const createStreamingCache: {
|
|
7
|
-
/**
|
|
8
|
-
* Create cache optimized for API responses
|
|
9
|
-
*/
|
|
10
|
-
api: (maxSize: number?) => any;
|
|
11
|
-
/**
|
|
12
|
-
* Create cache optimized for static assets
|
|
13
|
-
*/
|
|
14
|
-
assets: (maxSize: number?) => any;
|
|
15
|
-
/**
|
|
16
|
-
* Create cache optimized for HTML pages
|
|
17
|
-
*/
|
|
18
|
-
pages: (maxSize: number?) => any;
|
|
19
|
-
/**
|
|
20
|
-
* Create custom configured streaming cache
|
|
21
|
-
*/
|
|
22
|
-
custom: (options: StreamingCacheOptions) => any
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Response streaming cache for large responses
|
|
26
|
-
* Optimized for handling large payloads with memory-efficient streaming
|
|
27
|
-
*/
|
|
28
|
-
export declare interface StreamingCacheOptions extends Omit<LRUCacheOptions, 'maxSize'> {
|
|
29
|
-
maxSize: number
|
|
30
|
-
maxResponseSize: number
|
|
31
|
-
chunkSize: number
|
|
32
|
-
compressionEnabled: boolean
|
|
33
|
-
compressionThreshold: number
|
|
34
|
-
}
|
|
35
|
-
export declare interface CachedResponse {
|
|
36
|
-
status: number
|
|
37
|
-
statusText: string
|
|
38
|
-
headers: Record<string, string>
|
|
39
|
-
body: Uint8Array | null
|
|
40
|
-
compressed: boolean
|
|
41
|
-
originalSize: number
|
|
42
|
-
timestamp: number
|
|
43
|
-
etag?: string
|
|
44
|
-
}
|
|
45
|
-
export declare interface StreamingCacheStats {
|
|
46
|
-
totalResponses: number
|
|
47
|
-
totalSize: number
|
|
48
|
-
compressionRatio: number
|
|
49
|
-
averageResponseSize: number
|
|
50
|
-
largestResponse: number
|
|
51
|
-
streamingHits: number
|
|
52
|
-
streamingMisses: number
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* High-performance streaming cache for large HTTP responses
|
|
56
|
-
*/
|
|
57
|
-
export declare class StreamingCache {
|
|
58
|
-
private cache: LRUCache<CachedResponse>;
|
|
59
|
-
private stats: StreamingCacheStats;
|
|
60
|
-
private options: StreamingCacheOptions;
|
|
61
|
-
constructor(options: StreamingCacheOptions);
|
|
62
|
-
cacheResponse(key: string, response: Response, options?: {
|
|
63
|
-
ttl?: number
|
|
64
|
-
forceCache?: boolean
|
|
65
|
-
generateETag?: boolean
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
getStreamingResponse(key: string): Promise<Response | null>;
|
|
68
|
-
shouldCache(response: Response): boolean;
|
|
69
|
-
warmCache(routes: Array<{
|
|
70
|
-
key: string
|
|
71
|
-
url: string
|
|
72
|
-
method?: string
|
|
73
|
-
headers?: Record<string, string>
|
|
74
|
-
}>): Promise<number>;
|
|
75
|
-
createConditionalResponse(key: string, ifNoneMatch?: string): Response | null;
|
|
76
|
-
getStats(): StreamingCacheStats & { lruStats: any };
|
|
77
|
-
clear(): void;
|
|
78
|
-
prune(): number;
|
|
79
|
-
private createStreamingResponse(body: Uint8Array, cachedResponse: CachedResponse, headers: Headers): Response;
|
|
80
|
-
private extractHeaders(response: Response): Record<string, string>;
|
|
81
|
-
private compressData(data: Uint8Array): Promise<Uint8Array>;
|
|
82
|
-
private decompressData(data: Uint8Array): Promise<Uint8Array>;
|
|
83
|
-
private generateETag(data: Uint8Array): Promise<string>;
|
|
84
|
-
private updateStatsOnCache(originalSize: number, compressedSize: number): void;
|
|
85
|
-
private updateStatsOnEviction(cachedResponse: CachedResponse): void;
|
|
86
|
-
}
|
package/dist/cli/colors.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const chalk: {
|
|
2
|
-
red: (text: string) => unknown;
|
|
3
|
-
green: (text: string) => unknown;
|
|
4
|
-
yellow: (text: string) => unknown;
|
|
5
|
-
blue: (text: string) => unknown;
|
|
6
|
-
cyan: (text: string) => unknown;
|
|
7
|
-
white: (text: string) => unknown;
|
|
8
|
-
gray: (text: string) => unknown;
|
|
9
|
-
bold: (text: string) => unknown;
|
|
10
|
-
dim: (text: string) => unknown;
|
|
11
|
-
hex: (_color: string) => unknown
|
|
12
|
-
};
|
package/dist/cli/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CLI } from '@stacksjs/clapp';
|
|
2
|
-
/**
|
|
3
|
-
* Create and configure the CLI
|
|
4
|
-
*/
|
|
5
|
-
export declare function createCLI(): CLI;
|
|
6
|
-
export * from './middleware';
|
|
7
|
-
export * from './openapi';
|
|
8
|
-
export * from './router';
|
|
9
|
-
export * from './routes';
|
|
10
|
-
export * from './utils';
|
package/dist/cli/middleware.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate TypeScript types for middleware configurations
|
|
3
|
-
*/
|
|
4
|
-
export declare function generateMiddlewareTypes(outputPath: string): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Generate middleware type mappings for user project
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateMiddlewareMap(directoryPath: string, outputPath: string): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Watch for changes in the directory and regenerate middleware map
|
|
11
|
-
*/
|
|
12
|
-
export declare function watchDirectoryForMiddleware(directoryPath: string, outputPath: string): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Watch for changes in the middleware directory and regenerate types
|
|
15
|
-
*/
|
|
16
|
-
export declare function watchMiddlewareDirectory(outputPath: string): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Options for the middleware:types command
|
|
19
|
-
*/
|
|
20
|
-
export declare interface GenerateMiddlewareTypesOptions {
|
|
21
|
-
output?: string
|
|
22
|
-
watch?: boolean
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Options for the middleware:map command
|
|
26
|
-
*/
|
|
27
|
-
export declare interface MapMiddlewareOptions {
|
|
28
|
-
output?: string
|
|
29
|
-
dir?: string
|
|
30
|
-
watch?: boolean
|
|
31
|
-
}
|