@stacksjs/bun-router 0.0.12 → 0.0.14
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/CHANGELOG.md +770 -0
- package/README.md +584 -261
- package/package.json +43 -48
- package/bin/cli.ts +0 -9
- package/dist/auth.d.ts +0 -134
- package/dist/cache/lru-cache.d.ts +0 -139
- package/dist/cache/middleware-memoization.d.ts +0 -151
- package/dist/cache/route-cache-warmer.d.ts +0 -161
- package/dist/cache/sqlite-cache.d.ts +0 -209
- package/dist/cache/streaming-cache.d.ts +0 -132
- package/dist/chunk-1mvtv6jw.js +0 -13012
- package/dist/cli/colors.d.ts +0 -15
- 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 -29
- package/dist/cli/utils.d.ts +0 -74
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -3195
- package/dist/config.d.ts +0 -7
- package/dist/container/container.d.ts +0 -273
- package/dist/container/contextual-binding.d.ts +0 -240
- package/dist/container/decorators.d.ts +0 -141
- package/dist/container/service-provider.d.ts +0 -285
- package/dist/development/hot-reload.d.ts +0 -187
- package/dist/development/index.d.ts +0 -167
- package/dist/development/performance-profiler.d.ts +0 -217
- package/dist/development/route-debugger.d.ts +0 -154
- package/dist/development/route-inspector.d.ts +0 -211
- package/dist/development/typescript-utilities.d.ts +0 -209
- package/dist/docs.d.ts +0 -11
- package/dist/errors/circuit-breaker.d.ts +0 -195
- package/dist/errors/error-handler.d.ts +0 -88
- package/dist/errors/error-reporting.d.ts +0 -144
- package/dist/errors/exceptions.d.ts +0 -184
- package/dist/errors/graceful-degradation.d.ts +0 -154
- package/dist/errors/index.d.ts +0 -9
- package/dist/errors/router-errors.d.ts +0 -110
- package/dist/file-serving/static-files.d.ts +0 -143
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13933
- package/dist/middleware/auth.d.ts +0 -63
- package/dist/middleware/content_security_policy.d.ts +0 -53
- package/dist/middleware/cors.d.ts +0 -5
- package/dist/middleware/csrf.d.ts +0 -7
- package/dist/middleware/ddos_protection.d.ts +0 -39
- package/dist/middleware/file_security.d.ts +0 -26
- package/dist/middleware/file_upload.d.ts +0 -38
- package/dist/middleware/helmet.d.ts +0 -54
- package/dist/middleware/index.d.ts +0 -44
- package/dist/middleware/input_validation.d.ts +0 -45
- package/dist/middleware/json_body.d.ts +0 -4
- package/dist/middleware/performance_alerting.d.ts +0 -87
- package/dist/middleware/performance_dashboard.d.ts +0 -87
- package/dist/middleware/performance_monitor.d.ts +0 -209
- package/dist/middleware/pipeline.d.ts +0 -131
- package/dist/middleware/rate_limit.d.ts +0 -36
- package/dist/middleware/request_id.d.ts +0 -4
- package/dist/middleware/request_signing.d.ts +0 -153
- package/dist/middleware/request_tracer.d.ts +0 -72
- package/dist/middleware/response_cache.d.ts +0 -97
- package/dist/middleware/security.d.ts +0 -69
- package/dist/middleware/security_suite.d.ts +0 -46
- package/dist/middleware/session.d.ts +0 -23
- package/dist/model-binding/index.d.ts +0 -2
- package/dist/model-binding/model-middleware.d.ts +0 -118
- package/dist/model-binding/model-registry.d.ts +0 -164
- package/dist/model-binding.d.ts +0 -185
- package/dist/model-resolver-factory.d.ts +0 -31
- package/dist/observability/correlation.d.ts +0 -187
- package/dist/observability/health-checks.d.ts +0 -186
- package/dist/observability/index.d.ts +0 -60
- package/dist/observability/integration.d.ts +0 -147
- package/dist/observability/metrics.d.ts +0 -184
- package/dist/observability/tracing.d.ts +0 -187
- package/dist/optimization/bun-utilities.d.ts +0 -224
- package/dist/query-builder-integration.d.ts +0 -36
- package/dist/request/context.d.ts +0 -34
- package/dist/request/enhanced-request.d.ts +0 -213
- package/dist/request/macros.d.ts +0 -300
- package/dist/response/macros.d.ts +0 -245
- package/dist/response/response-factory.d.ts +0 -133
- package/dist/router/api-routes.d.ts +0 -5
- package/dist/router/file-based-routing.d.ts +0 -118
- package/dist/router/file-streaming.d.ts +0 -5
- package/dist/router/fluent-router.d.ts +0 -315
- package/dist/router/fluent-routing.d.ts +0 -271
- package/dist/router/group-organization.d.ts +0 -5
- package/dist/router/handler-resolver.d.ts +0 -24
- package/dist/router/http-methods.d.ts +0 -10
- package/dist/router/index.d.ts +0 -114
- package/dist/router/middleware-groups.d.ts +0 -94
- package/dist/router/middleware-integration.d.ts +0 -112
- package/dist/router/middleware.d.ts +0 -5
- package/dist/router/model-binding.d.ts +0 -5
- 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 -153
- package/dist/router/route-matching.d.ts +0 -5
- package/dist/router/route-trie.d.ts +0 -114
- package/dist/router/router.d.ts +0 -294
- package/dist/router/server.d.ts +0 -5
- package/dist/router/validation-integration.d.ts +0 -170
- 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 -129
- package/dist/routing/route-throttling.d.ts +0 -150
- package/dist/routing/subdomain-routing.d.ts +0 -206
- package/dist/session/database-store.d.ts +0 -51
- package/dist/session/file-store.d.ts +0 -22
- package/dist/session/index.d.ts +0 -106
- package/dist/session/memory-store.d.ts +0 -21
- package/dist/session/redis-store.d.ts +0 -31
- package/dist/streaming/index.d.ts +0 -3
- package/dist/streaming/sse-handler.d.ts +0 -138
- package/dist/streaming/stream-handler.d.ts +0 -114
- package/dist/testing/auth-testing.d.ts +0 -156
- package/dist/testing/file-upload-testing.d.ts +0 -190
- package/dist/testing/index.d.ts +0 -10
- package/dist/testing/middleware-testing.d.ts +0 -138
- package/dist/testing/model-binding-testing.d.ts +0 -186
- package/dist/testing/performance-testing.d.ts +0 -235
- package/dist/testing/test-client.d.ts +0 -117
- package/dist/testing/test-request.d.ts +0 -85
- package/dist/testing/test-response.d.ts +0 -90
- package/dist/testing/types.d.ts +0 -207
- package/dist/testing/websocket-testing.d.ts +0 -227
- package/dist/types/controller-types.d.ts +0 -208
- package/dist/types/core.d.ts +0 -543
- package/dist/types/middleware-types.d.ts +0 -227
- package/dist/types/request-response-augmentation.d.ts +0 -261
- package/dist/types/route-inference.d.ts +0 -168
- package/dist/types.d.ts +0 -1782
- package/dist/url.d.ts +0 -56
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/query-preservation.d.ts +0 -48
- package/dist/utils.d.ts +0 -69
- package/dist/validation/validator.d.ts +0 -140
- package/dist/websocket/clustering.d.ts +0 -185
- package/src/auth.ts +0 -469
- package/src/cache/lru-cache.ts +0 -457
- package/src/cache/middleware-memoization.ts +0 -531
- package/src/cache/route-cache-warmer.ts +0 -486
- package/src/cache/sqlite-cache.ts +0 -783
- package/src/cache/streaming-cache.ts +0 -572
- package/src/cli/colors.ts +0 -29
- package/src/cli/index.ts +0 -287
- package/src/cli/middleware.ts +0 -291
- package/src/cli/openapi.ts +0 -407
- package/src/cli/router.ts +0 -188
- package/src/cli/routes.ts +0 -265
- package/src/cli/utils.ts +0 -531
- package/src/cli.ts +0 -5
- package/src/config.ts +0 -322
- package/src/container/container.ts +0 -740
- package/src/container/contextual-binding.ts +0 -603
- package/src/container/decorators.ts +0 -359
- package/src/container/service-provider.ts +0 -596
- package/src/development/hot-reload.ts +0 -673
- package/src/development/index.ts +0 -499
- package/src/development/performance-profiler.ts +0 -717
- package/src/development/route-debugger.ts +0 -527
- package/src/development/route-inspector.ts +0 -749
- package/src/development/typescript-utilities.ts +0 -682
- package/src/docs.ts +0 -397
- package/src/errors/circuit-breaker.ts +0 -732
- package/src/errors/error-handler.ts +0 -569
- package/src/errors/error-reporting.ts +0 -672
- package/src/errors/exceptions.ts +0 -536
- package/src/errors/graceful-degradation.ts +0 -621
- package/src/errors/index.ts +0 -21
- package/src/errors/router-errors.ts +0 -632
- package/src/file-serving/static-files.ts +0 -581
- package/src/index.ts +0 -14
- package/src/middleware/auth.ts +0 -219
- package/src/middleware/content_security_policy.ts +0 -215
- package/src/middleware/cors.ts +0 -74
- package/src/middleware/csrf.ts +0 -108
- package/src/middleware/ddos_protection.ts +0 -255
- package/src/middleware/file_security.ts +0 -191
- package/src/middleware/file_upload.ts +0 -264
- package/src/middleware/helmet.ts +0 -268
- package/src/middleware/index.ts +0 -117
- package/src/middleware/input_validation.ts +0 -449
- package/src/middleware/json_body.ts +0 -37
- package/src/middleware/performance_alerting.ts +0 -538
- package/src/middleware/performance_dashboard.ts +0 -661
- package/src/middleware/performance_monitor.ts +0 -943
- package/src/middleware/pipeline.ts +0 -489
- package/src/middleware/rate_limit.ts +0 -245
- package/src/middleware/request_id.ts +0 -36
- package/src/middleware/request_signing.ts +0 -636
- package/src/middleware/request_tracer.ts +0 -636
- package/src/middleware/response_cache.ts +0 -743
- package/src/middleware/security.ts +0 -482
- package/src/middleware/security_suite.ts +0 -257
- package/src/middleware/session.ts +0 -91
- package/src/model-binding/index.ts +0 -18
- package/src/model-binding/model-middleware.ts +0 -425
- package/src/model-binding/model-registry.ts +0 -550
- package/src/model-binding.ts +0 -370
- package/src/model-resolver-factory.ts +0 -106
- package/src/observability/correlation.ts +0 -691
- package/src/observability/health-checks.ts +0 -729
- package/src/observability/index.ts +0 -184
- package/src/observability/integration.ts +0 -548
- package/src/observability/metrics.ts +0 -753
- package/src/observability/tracing.ts +0 -638
- package/src/optimization/bun-utilities.ts +0 -778
- package/src/query-builder-integration.ts +0 -137
- package/src/request/context.ts +0 -62
- package/src/request/enhanced-request.ts +0 -857
- package/src/request/macros.ts +0 -688
- package/src/response/macros.ts +0 -612
- package/src/response/response-factory.ts +0 -596
- package/src/router/api-routes.ts +0 -243
- package/src/router/file-based-routing.ts +0 -670
- package/src/router/file-streaming.ts +0 -372
- package/src/router/fluent-router.ts +0 -927
- package/src/router/fluent-routing.ts +0 -797
- package/src/router/group-organization.ts +0 -213
- package/src/router/handler-resolver.ts +0 -291
- package/src/router/http-methods.ts +0 -377
- package/src/router/index.ts +0 -187
- package/src/router/middleware-groups.ts +0 -222
- package/src/router/middleware-integration.ts +0 -399
- package/src/router/middleware.ts +0 -231
- package/src/router/model-binding.ts +0 -215
- package/src/router/optimized-route-matching.ts +0 -253
- package/src/router/route-building.ts +0 -212
- package/src/router/route-compiler.ts +0 -702
- package/src/router/route-matching.ts +0 -349
- package/src/router/route-trie.ts +0 -464
- package/src/router/router.ts +0 -1581
- package/src/router/server.ts +0 -462
- package/src/router/validation-integration.ts +0 -443
- package/src/router/view-rendering.ts +0 -233
- package/src/router/websocket.ts +0 -100
- package/src/routing/route-caching.ts +0 -402
- package/src/routing/route-throttling.ts +0 -469
- package/src/routing/subdomain-routing.ts +0 -492
- package/src/session/database-store.ts +0 -109
- package/src/session/file-store.ts +0 -148
- package/src/session/index.ts +0 -244
- package/src/session/memory-store.ts +0 -88
- package/src/session/redis-store.ts +0 -93
- package/src/streaming/index.ts +0 -17
- package/src/streaming/sse-handler.ts +0 -482
- package/src/streaming/stream-handler.ts +0 -552
- package/src/testing/auth-testing.ts +0 -446
- package/src/testing/file-upload-testing.ts +0 -543
- package/src/testing/index.ts +0 -10
- package/src/testing/middleware-testing.ts +0 -322
- package/src/testing/model-binding-testing.ts +0 -645
- package/src/testing/performance-testing.ts +0 -738
- package/src/testing/test-client.ts +0 -310
- package/src/testing/test-request.ts +0 -315
- package/src/testing/test-response.ts +0 -332
- package/src/testing/types.ts +0 -224
- package/src/testing/websocket-testing.ts +0 -590
- package/src/types/controller-types.ts +0 -385
- package/src/types/core.ts +0 -683
- package/src/types/middleware-types.ts +0 -419
- package/src/types/request-response-augmentation.ts +0 -489
- package/src/types/route-inference.ts +0 -357
- package/src/types.ts +0 -2055
- package/src/url.ts +0 -126
- package/src/utils/index.ts +0 -1
- package/src/utils/query-preservation.ts +0 -201
- package/src/utils.ts +0 -327
- package/src/validation/validator.ts +0 -685
- package/src/websocket/clustering.ts +0 -762
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/bun-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"
|
|
4
|
+
"version": "0.0.14",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "A router for Bun.",
|
|
6
7
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"homepage": "https://github.com/stacksjs/bun-router#readme",
|
|
@@ -15,80 +16,74 @@
|
|
|
15
16
|
},
|
|
16
17
|
"keywords": [
|
|
17
18
|
"router",
|
|
18
|
-
"route",
|
|
19
|
-
"server",
|
|
20
|
-
"laravel",
|
|
21
|
-
"fast",
|
|
22
19
|
"bun",
|
|
23
20
|
"typescript"
|
|
24
21
|
],
|
|
25
22
|
"exports": {
|
|
26
23
|
".": {
|
|
27
|
-
"bun": "./dist/index.js",
|
|
28
24
|
"types": "./dist/index.d.ts",
|
|
29
25
|
"import": "./dist/index.js"
|
|
30
26
|
},
|
|
31
27
|
"./*": {
|
|
32
|
-
"bun": "./dist/*",
|
|
33
28
|
"import": "./dist/*"
|
|
34
29
|
}
|
|
35
30
|
},
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"exports": {
|
|
38
|
-
".": {
|
|
39
|
-
"bun": "./dist/index.js",
|
|
40
|
-
"types": "./dist/index.d.ts",
|
|
41
|
-
"import": "./dist/index.js"
|
|
42
|
-
},
|
|
43
|
-
"./*": {
|
|
44
|
-
"bun": "./dist/*",
|
|
45
|
-
"import": "./dist/*"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
31
|
"module": "./dist/index.js",
|
|
50
32
|
"types": "./dist/index.d.ts",
|
|
51
|
-
"bin": {
|
|
52
|
-
"bun-router": "./dist/cli.js",
|
|
53
|
-
"router": "./bin/cli.ts"
|
|
54
|
-
},
|
|
55
33
|
"files": [
|
|
56
34
|
"README.md",
|
|
57
|
-
"dist"
|
|
58
|
-
"src"
|
|
35
|
+
"dist"
|
|
59
36
|
],
|
|
60
37
|
"scripts": {
|
|
61
|
-
"build": "
|
|
38
|
+
"build": "cd ./packages/bun-router && bun run build",
|
|
62
39
|
"compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/router",
|
|
63
40
|
"compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
|
|
64
|
-
"compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/router-linux-x64",
|
|
65
|
-
"compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/router-linux-arm64",
|
|
66
|
-
"compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/router-windows-x64.exe",
|
|
67
|
-
"compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/router-darwin-x64",
|
|
68
|
-
"compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/router-darwin-arm64",
|
|
41
|
+
"compile:linux-x64": "bun build ./packages/bun-router/bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile ./packages/bun-router/dist/bin/router-linux-x64",
|
|
42
|
+
"compile:linux-arm64": "bun build ./packages/bun-router/bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile ./packages/bun-router/dist/bin/router-linux-arm64",
|
|
43
|
+
"compile:windows-x64": "bun build ./packages/bun-router/bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile ./packages/bun-router/dist/bin/router-windows-x64.exe",
|
|
44
|
+
"compile:darwin-x64": "bun build ./packages/bun-router/bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile ./packages/bun-router/dist/bin/router-darwin-x64",
|
|
45
|
+
"compile:darwin-arm64": "bun build ./packages/bun-router/bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile ./packages/bun-router/dist/bin/router-darwin-arm64",
|
|
69
46
|
"zip": "bun run zip:all",
|
|
70
47
|
"zip:all": "bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:windows-x64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64",
|
|
71
|
-
"zip:linux-x64": "zip -j bin/router-linux-x64.zip bin/router-linux-x64",
|
|
72
|
-
"zip:linux-arm64": "zip -j bin/router-linux-arm64.zip bin/router-linux-arm64",
|
|
73
|
-
"zip:windows-x64": "zip -j bin/router-windows-x64.zip bin/router-windows-x64.exe",
|
|
74
|
-
"zip:darwin-x64": "zip -j bin/router-darwin-x64.zip bin/router-darwin-x64",
|
|
75
|
-
"zip:darwin-arm64": "zip -j bin/router-darwin-arm64.zip bin/router-darwin-arm64",
|
|
76
|
-
"lint": "bunx --bun eslint .",
|
|
77
|
-
"lint:fix": "bunx --bun eslint . --fix",
|
|
48
|
+
"zip:linux-x64": "zip -j ./packages/bun-router/dist/bin/router-linux-x64.zip ./packages/bun-router/dist/bin/router-linux-x64",
|
|
49
|
+
"zip:linux-arm64": "zip -j ./packages/bun-router/dist/bin/router-linux-arm64.zip ./packages/bun-router/dist/bin/router-linux-arm64",
|
|
50
|
+
"zip:windows-x64": "zip -j ./packages/bun-router/dist/bin/router-windows-x64.zip ./packages/bun-router/dist/bin/router-windows-x64.exe",
|
|
51
|
+
"zip:darwin-x64": "zip -j ./packages/bun-router/dist/bin/router-darwin-x64.zip ./packages/bun-router/dist/bin/router-darwin-x64",
|
|
52
|
+
"zip:darwin-arm64": "zip -j ./packages/bun-router/dist/bin/router-darwin-arm64.zip ./packages/bun-router/dist/bin/router-darwin-arm64",
|
|
78
53
|
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
|
|
79
|
-
"changelog": "bunx changelogen --output CHANGELOG.md",
|
|
80
54
|
"prepublishOnly": "bun --bun run build",
|
|
81
55
|
"package:bin": "bun run compile:all && bun run zip",
|
|
82
|
-
"release": "bun run changelog && bunx bumpp package.json --all",
|
|
83
56
|
"test": "bun test",
|
|
57
|
+
"lint": "bunx --bun pickier .",
|
|
58
|
+
"lint:fix": "bunx --bun pickier . --fix",
|
|
59
|
+
"format": "bunx --bun pickier . --format",
|
|
60
|
+
"format:fix": "bunx --bun pickier . --format --write",
|
|
61
|
+
"changelog": "bunx logsmith --verbose",
|
|
62
|
+
"changelog:generate": "bunx logsmith --output CHANGELOG.md",
|
|
63
|
+
"release": "bun --bun run changelog:generate && bunx --bun bumpx prompt --recursive",
|
|
64
|
+
"release:patch": "bun --bun run changelog:generate && bunx --bun bumpx patch --recursive --yes",
|
|
65
|
+
"publish:patch": "bun --bun run changelog:generate && bunx --bun bumpx patch --recursive --yes",
|
|
66
|
+
"release:minor": "bun --bun run changelog:generate && bunx --bun bumpx minor --recursive --yes && cd packages/bun-router && bun publish",
|
|
67
|
+
"release:major": "bun --bun run changelog:generate && bunx --bun bumpx major --recursive --yes && cd packages/bun-router && bun publish",
|
|
68
|
+
"dev:docs": "bun --bun bunpress dev docs",
|
|
69
|
+
"build:docs": "bun --bun bunpress build docs",
|
|
70
|
+
"preview:docs": "bun --bun bunpress preview docs",
|
|
71
|
+
"deploy:docs": "bunx bunpress deploy --domain bun-router.stacksjs.com",
|
|
84
72
|
"typecheck": "bunx --bun tsc --noEmit"
|
|
85
73
|
},
|
|
86
|
-
"
|
|
87
|
-
"@stacksjs/
|
|
88
|
-
"
|
|
89
|
-
"ts-rate-limiter": "^0.4.2"
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@stacksjs/bunpress": "^0.1.4",
|
|
76
|
+
"better-dx": "^0.2.7"
|
|
90
77
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
78
|
+
"workspaces": [
|
|
79
|
+
"packages/*"
|
|
80
|
+
],
|
|
81
|
+
"git-hooks": {
|
|
82
|
+
"pre-commit": {
|
|
83
|
+
"staged-lint": {
|
|
84
|
+
"*.{js,ts,json,yaml,yml,md}": "bunx --bun pickier lint --fix"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"commit-msg": "bunx gitlint --edit .git/COMMIT_EDITMSG"
|
|
93
88
|
}
|
|
94
89
|
}
|
package/bin/cli.ts
DELETED
package/dist/auth.d.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, JwtPayload } from './types';
|
|
2
|
-
export interface JwtVerifyOptions {
|
|
3
|
-
issuer?: string;
|
|
4
|
-
audience?: string;
|
|
5
|
-
subject?: string;
|
|
6
|
-
algorithms?: string[];
|
|
7
|
-
expiresIn?: string | number;
|
|
8
|
-
notBefore?: string | number;
|
|
9
|
-
ignoreExpiration?: boolean;
|
|
10
|
-
allowInvalidAsymmetricKeyTypes?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface JwtSignOptions {
|
|
13
|
-
algorithm?: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512' | 'PS256' | 'PS384' | 'PS512' | 'none';
|
|
14
|
-
expiresIn?: string | number;
|
|
15
|
-
notBefore?: string | number;
|
|
16
|
-
audience?: string | string[];
|
|
17
|
-
issuer?: string;
|
|
18
|
-
subject?: string;
|
|
19
|
-
keyid?: string;
|
|
20
|
-
jwtid?: string;
|
|
21
|
-
noTimestamp?: boolean;
|
|
22
|
-
header?: Record<string, any>;
|
|
23
|
-
encoding?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ApiKeyOptions {
|
|
26
|
-
source?: 'header' | 'query' | 'cookie';
|
|
27
|
-
keyName?: string;
|
|
28
|
-
keyPrefix?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface OAuth2Config {
|
|
31
|
-
clientId: string;
|
|
32
|
-
clientSecret: string;
|
|
33
|
-
authorizeUrl: string;
|
|
34
|
-
tokenUrl: string;
|
|
35
|
-
redirectUri: string;
|
|
36
|
-
scope?: string;
|
|
37
|
-
state?: string;
|
|
38
|
-
}
|
|
39
|
-
export type { JwtPayload };
|
|
40
|
-
/**
|
|
41
|
-
* Simple JWT implementation for signing and verifying tokens
|
|
42
|
-
*/
|
|
43
|
-
export declare class JWT {
|
|
44
|
-
private secret;
|
|
45
|
-
constructor(secret: string);
|
|
46
|
-
/**
|
|
47
|
-
* Sign payload into a JWT token
|
|
48
|
-
*/
|
|
49
|
-
sign(payload: Record<string, any>, options?: JwtSignOptions): string;
|
|
50
|
-
/**
|
|
51
|
-
* Verify a JWT token and return the decoded payload
|
|
52
|
-
*/
|
|
53
|
-
verify(token: string, options?: JwtVerifyOptions): Record<string, any> | null;
|
|
54
|
-
/**
|
|
55
|
-
* Decode a JWT token without verifying the signature
|
|
56
|
-
*/
|
|
57
|
-
decode(token: string): {
|
|
58
|
-
header: Record<string, any>;
|
|
59
|
-
payload: Record<string, any>;
|
|
60
|
-
} | null;
|
|
61
|
-
/**
|
|
62
|
-
* Simple signature creation - Note: This is NOT secure for production
|
|
63
|
-
* In a real app, use Bun's crypto functionality or a dedicated JWT library
|
|
64
|
-
*/
|
|
65
|
-
private createSignature;
|
|
66
|
-
/**
|
|
67
|
-
* Parse timespan string to seconds
|
|
68
|
-
*/
|
|
69
|
-
private parseTimespan;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* API Key manager to generate, validate and handle API keys
|
|
73
|
-
*/
|
|
74
|
-
export declare class ApiKeyManager {
|
|
75
|
-
private keys;
|
|
76
|
-
private options;
|
|
77
|
-
constructor(options?: ApiKeyOptions);
|
|
78
|
-
/**
|
|
79
|
-
* Generate a new API key
|
|
80
|
-
*/
|
|
81
|
-
generateKey(owner: string, scopes?: string[], expiresIn?: number): string;
|
|
82
|
-
/**
|
|
83
|
-
* Validate an API key
|
|
84
|
-
*/
|
|
85
|
-
validateKey(key: string, requiredScopes?: string[]): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Get key information
|
|
88
|
-
*/
|
|
89
|
-
getKeyInfo(key: string): {
|
|
90
|
-
owner: string;
|
|
91
|
-
scopes: string[];
|
|
92
|
-
expiresAt?: Date;
|
|
93
|
-
} | null;
|
|
94
|
-
/**
|
|
95
|
-
* Revoke an API key
|
|
96
|
-
*/
|
|
97
|
-
revokeKey(key: string): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Extract API key from request based on configured source
|
|
100
|
-
*/
|
|
101
|
-
extractFromRequest(req: EnhancedRequest): string | null;
|
|
102
|
-
/**
|
|
103
|
-
* Generate a random string for keys
|
|
104
|
-
*/
|
|
105
|
-
private randomString;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* OAuth2 helper for authorization code flow
|
|
109
|
-
*/
|
|
110
|
-
export declare class OAuth2Helper {
|
|
111
|
-
private config;
|
|
112
|
-
constructor(config: OAuth2Config);
|
|
113
|
-
/**
|
|
114
|
-
* Generate authorization URL for redirect
|
|
115
|
-
*/
|
|
116
|
-
getAuthorizationUrl(additionalParams?: Record<string, string>): string;
|
|
117
|
-
/**
|
|
118
|
-
* Exchange authorization code for access token
|
|
119
|
-
*/
|
|
120
|
-
exchangeCodeForToken(code: string): Promise<Record<string, any>>;
|
|
121
|
-
/**
|
|
122
|
-
* Refresh an access token using a refresh token
|
|
123
|
-
*/
|
|
124
|
-
refreshToken(refreshToken: string): Promise<Record<string, any>>;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Authentication helpers namespace
|
|
128
|
-
*/
|
|
129
|
-
declare const Auth: {
|
|
130
|
-
JWT: typeof JWT;
|
|
131
|
-
ApiKeyManager: typeof ApiKeyManager;
|
|
132
|
-
OAuth2Helper: typeof OAuth2Helper;
|
|
133
|
-
};
|
|
134
|
-
export default Auth;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-performance LRU (Least Recently Used) cache implementation
|
|
3
|
-
* Optimized for Bun runtime with configurable size limits and TTL support
|
|
4
|
-
*/
|
|
5
|
-
export interface LRUCacheOptions {
|
|
6
|
-
maxSize: number;
|
|
7
|
-
ttl?: number;
|
|
8
|
-
onEvict?: (key: string, value: any) => void;
|
|
9
|
-
allowStale?: boolean;
|
|
10
|
-
updateAgeOnGet?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface CacheEntry<T = any> {
|
|
13
|
-
value: T;
|
|
14
|
-
timestamp: number;
|
|
15
|
-
accessCount: number;
|
|
16
|
-
lastAccessed: number;
|
|
17
|
-
ttl?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface CacheStats {
|
|
20
|
-
size: number;
|
|
21
|
-
maxSize: number;
|
|
22
|
-
hits: number;
|
|
23
|
-
misses: number;
|
|
24
|
-
evictions: number;
|
|
25
|
-
hitRate: number;
|
|
26
|
-
memoryUsage: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* High-performance LRU cache with TTL support and detailed statistics
|
|
30
|
-
*/
|
|
31
|
-
export declare class LRUCache<T = any> {
|
|
32
|
-
private options;
|
|
33
|
-
private cache;
|
|
34
|
-
private head;
|
|
35
|
-
private tail;
|
|
36
|
-
private stats;
|
|
37
|
-
constructor(options: LRUCacheOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Get value from cache
|
|
40
|
-
*/
|
|
41
|
-
get(key: string): T | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Set value in cache
|
|
44
|
-
*/
|
|
45
|
-
set(key: string, value: T, ttl?: number): void;
|
|
46
|
-
/**
|
|
47
|
-
* Delete key from cache
|
|
48
|
-
*/
|
|
49
|
-
delete(key: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Check if key exists in cache (without updating access time)
|
|
52
|
-
*/
|
|
53
|
-
has(key: string): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Clear all entries from cache
|
|
56
|
-
*/
|
|
57
|
-
clear(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Get all keys in cache (ordered by recency)
|
|
60
|
-
*/
|
|
61
|
-
keys(): string[];
|
|
62
|
-
/**
|
|
63
|
-
* Get all values in cache (ordered by recency)
|
|
64
|
-
*/
|
|
65
|
-
values(): T[];
|
|
66
|
-
/**
|
|
67
|
-
* Get cache statistics
|
|
68
|
-
*/
|
|
69
|
-
getStats(): CacheStats;
|
|
70
|
-
/**
|
|
71
|
-
* Reset statistics
|
|
72
|
-
*/
|
|
73
|
-
resetStats(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Prune expired entries
|
|
76
|
-
*/
|
|
77
|
-
prune(): number;
|
|
78
|
-
/**
|
|
79
|
-
* Get entries sorted by access frequency
|
|
80
|
-
*/
|
|
81
|
-
getFrequentlyUsed(limit?: number): Array<{
|
|
82
|
-
key: string;
|
|
83
|
-
value: T;
|
|
84
|
-
accessCount: number;
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* Resize cache (may trigger evictions)
|
|
88
|
-
*/
|
|
89
|
-
resize(newMaxSize: number): void;
|
|
90
|
-
/**
|
|
91
|
-
* Check if entry is expired
|
|
92
|
-
*/
|
|
93
|
-
private isExpired;
|
|
94
|
-
/**
|
|
95
|
-
* Move node to front of list (most recently used)
|
|
96
|
-
*/
|
|
97
|
-
private moveToFront;
|
|
98
|
-
/**
|
|
99
|
-
* Add node to front of list
|
|
100
|
-
*/
|
|
101
|
-
private addToFront;
|
|
102
|
-
/**
|
|
103
|
-
* Remove node from list
|
|
104
|
-
*/
|
|
105
|
-
private removeNode;
|
|
106
|
-
/**
|
|
107
|
-
* Evict least recently used entry
|
|
108
|
-
*/
|
|
109
|
-
private evictLRU;
|
|
110
|
-
/**
|
|
111
|
-
* Estimate memory usage in bytes
|
|
112
|
-
*/
|
|
113
|
-
private estimateMemoryUsage;
|
|
114
|
-
/**
|
|
115
|
-
* Estimate size of a value in bytes
|
|
116
|
-
*/
|
|
117
|
-
private estimateValueSize;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Factory function to create LRU cache with common configurations
|
|
121
|
-
*/
|
|
122
|
-
export declare const createLRUCache: {
|
|
123
|
-
/**
|
|
124
|
-
* Create a small cache for frequently accessed items
|
|
125
|
-
*/
|
|
126
|
-
small: <T = any>(ttl?: number) => LRUCache<T>;
|
|
127
|
-
/**
|
|
128
|
-
* Create a medium cache for general purpose use
|
|
129
|
-
*/
|
|
130
|
-
medium: <T = any>(ttl?: number) => LRUCache<T>;
|
|
131
|
-
/**
|
|
132
|
-
* Create a large cache for heavy caching scenarios
|
|
133
|
-
*/
|
|
134
|
-
large: <T = any>(ttl?: number) => LRUCache<T>;
|
|
135
|
-
/**
|
|
136
|
-
* Create a custom configured cache
|
|
137
|
-
*/
|
|
138
|
-
custom: <T = any>(options: LRUCacheOptions) => LRUCache<T>;
|
|
139
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, MiddlewareHandler } from '../types';
|
|
2
|
-
import type { LRUCacheOptions } from './lru-cache';
|
|
3
|
-
/**
|
|
4
|
-
* Middleware result memoization for expensive operations
|
|
5
|
-
* Caches middleware results based on request characteristics
|
|
6
|
-
*/
|
|
7
|
-
export interface MemoizationOptions extends Omit<LRUCacheOptions, 'maxSize'> {
|
|
8
|
-
maxSize: number;
|
|
9
|
-
keyGenerator?: (req: EnhancedRequest) => string;
|
|
10
|
-
shouldMemoize?: (req: EnhancedRequest, result: any) => boolean;
|
|
11
|
-
resultSerializer?: (result: any) => any;
|
|
12
|
-
resultDeserializer?: (serialized: any) => any;
|
|
13
|
-
}
|
|
14
|
-
export interface MemoizedResult<T = any> {
|
|
15
|
-
value: T;
|
|
16
|
-
timestamp: number;
|
|
17
|
-
requestFingerprint: string;
|
|
18
|
-
executionTime: number;
|
|
19
|
-
hitCount: number;
|
|
20
|
-
}
|
|
21
|
-
export interface MemoizationStats {
|
|
22
|
-
totalRequests: number;
|
|
23
|
-
cacheHits: number;
|
|
24
|
-
cacheMisses: number;
|
|
25
|
-
hitRate: number;
|
|
26
|
-
averageExecutionTime: number;
|
|
27
|
-
totalTimeSaved: number;
|
|
28
|
-
memoryUsage: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Middleware memoization system for caching expensive operations
|
|
32
|
-
*/
|
|
33
|
-
export declare class MiddlewareMemoizer {
|
|
34
|
-
private options;
|
|
35
|
-
private cache;
|
|
36
|
-
private stats;
|
|
37
|
-
constructor(options: MemoizationOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Create a memoized version of a middleware function
|
|
40
|
-
*/
|
|
41
|
-
memoize<_T = any>(middleware: MiddlewareHandler, options?: {
|
|
42
|
-
name?: string;
|
|
43
|
-
keyGenerator?: (req: EnhancedRequest) => string;
|
|
44
|
-
shouldMemoize?: (req: EnhancedRequest, result: any) => boolean;
|
|
45
|
-
ttl?: number;
|
|
46
|
-
}): MiddlewareHandler;
|
|
47
|
-
/**
|
|
48
|
-
* Create a memoized async function (not middleware)
|
|
49
|
-
*/
|
|
50
|
-
memoizeFunction<TArgs extends any[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: {
|
|
51
|
-
name?: string;
|
|
52
|
-
keyGenerator?: (...args: TArgs) => string;
|
|
53
|
-
shouldMemoize?: (result: TResult, ...args: TArgs) => boolean;
|
|
54
|
-
ttl?: number;
|
|
55
|
-
}): (...args: TArgs) => Promise<TResult>;
|
|
56
|
-
/**
|
|
57
|
-
* Invalidate cached results by pattern
|
|
58
|
-
*/
|
|
59
|
-
invalidate(pattern: string | RegExp): number;
|
|
60
|
-
/**
|
|
61
|
-
* Invalidate cached results for specific user
|
|
62
|
-
*/
|
|
63
|
-
invalidateForUser(userId: string): number;
|
|
64
|
-
/**
|
|
65
|
-
* Invalidate cached results by tag
|
|
66
|
-
*/
|
|
67
|
-
invalidateByTag(tag: string): number;
|
|
68
|
-
/**
|
|
69
|
-
* Get most frequently used cached results
|
|
70
|
-
*/
|
|
71
|
-
getPopularResults(limit?: number): Array<{
|
|
72
|
-
key: string;
|
|
73
|
-
hitCount: number;
|
|
74
|
-
executionTime: number;
|
|
75
|
-
timeSaved: number;
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Get memoization statistics
|
|
79
|
-
*/
|
|
80
|
-
getStats(): MemoizationStats;
|
|
81
|
-
/**
|
|
82
|
-
* Clear cache and reset statistics
|
|
83
|
-
*/
|
|
84
|
-
clear(): void;
|
|
85
|
-
/**
|
|
86
|
-
* Prune expired entries
|
|
87
|
-
*/
|
|
88
|
-
prune(): number;
|
|
89
|
-
/**
|
|
90
|
-
* Generate cache key for middleware
|
|
91
|
-
*/
|
|
92
|
-
private generateCacheKey;
|
|
93
|
-
/**
|
|
94
|
-
* Generate request fingerprint for cache validation
|
|
95
|
-
*/
|
|
96
|
-
private generateRequestFingerprint;
|
|
97
|
-
/**
|
|
98
|
-
* Update hit rate statistics
|
|
99
|
-
*/
|
|
100
|
-
private updateHitRate;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Common memoization patterns and utilities
|
|
104
|
-
*/
|
|
105
|
-
export declare class MemoizationPatterns {
|
|
106
|
-
/**
|
|
107
|
-
* Memoize database queries
|
|
108
|
-
*/
|
|
109
|
-
static createDatabaseMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
110
|
-
/**
|
|
111
|
-
* Memoize API calls
|
|
112
|
-
*/
|
|
113
|
-
static createApiMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
114
|
-
/**
|
|
115
|
-
* Memoize authentication checks
|
|
116
|
-
*/
|
|
117
|
-
static createAuthMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
118
|
-
/**
|
|
119
|
-
* Memoize rate limiting checks
|
|
120
|
-
*/
|
|
121
|
-
static createRateLimitMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
122
|
-
/**
|
|
123
|
-
* Memoize expensive computations
|
|
124
|
-
*/
|
|
125
|
-
static createComputationMemoizer(options?: MemoizationOptions): MiddlewareMemoizer;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Decorator for memoizing class methods
|
|
129
|
-
*/
|
|
130
|
-
export declare function Memoize(options?: {
|
|
131
|
-
memoizer: MiddlewareMemoizer;
|
|
132
|
-
keyGenerator?: (...args: any[]) => string;
|
|
133
|
-
ttl?: number;
|
|
134
|
-
}): MethodDecorator;
|
|
135
|
-
/**
|
|
136
|
-
* Factory functions for creating memoizers
|
|
137
|
-
*/
|
|
138
|
-
export declare const createMemoizer: {
|
|
139
|
-
/**
|
|
140
|
-
* Create memoizer for development
|
|
141
|
-
*/
|
|
142
|
-
development: () => MiddlewareMemoizer;
|
|
143
|
-
/**
|
|
144
|
-
* Create memoizer for production
|
|
145
|
-
*/
|
|
146
|
-
production: () => MiddlewareMemoizer;
|
|
147
|
-
/**
|
|
148
|
-
* Create custom memoizer
|
|
149
|
-
*/
|
|
150
|
-
custom: (options: MemoizationOptions) => MiddlewareMemoizer;
|
|
151
|
-
};
|