@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.
Files changed (273) hide show
  1. package/CHANGELOG.md +770 -0
  2. package/README.md +584 -261
  3. package/package.json +43 -48
  4. package/bin/cli.ts +0 -9
  5. package/dist/auth.d.ts +0 -134
  6. package/dist/cache/lru-cache.d.ts +0 -139
  7. package/dist/cache/middleware-memoization.d.ts +0 -151
  8. package/dist/cache/route-cache-warmer.d.ts +0 -161
  9. package/dist/cache/sqlite-cache.d.ts +0 -209
  10. package/dist/cache/streaming-cache.d.ts +0 -132
  11. package/dist/chunk-1mvtv6jw.js +0 -13012
  12. package/dist/cli/colors.d.ts +0 -15
  13. package/dist/cli/index.d.ts +0 -10
  14. package/dist/cli/middleware.d.ts +0 -31
  15. package/dist/cli/openapi.d.ts +0 -17
  16. package/dist/cli/router.d.ts +0 -15
  17. package/dist/cli/routes.d.ts +0 -29
  18. package/dist/cli/utils.d.ts +0 -74
  19. package/dist/cli.d.ts +0 -1
  20. package/dist/cli.js +0 -3195
  21. package/dist/config.d.ts +0 -7
  22. package/dist/container/container.d.ts +0 -273
  23. package/dist/container/contextual-binding.d.ts +0 -240
  24. package/dist/container/decorators.d.ts +0 -141
  25. package/dist/container/service-provider.d.ts +0 -285
  26. package/dist/development/hot-reload.d.ts +0 -187
  27. package/dist/development/index.d.ts +0 -167
  28. package/dist/development/performance-profiler.d.ts +0 -217
  29. package/dist/development/route-debugger.d.ts +0 -154
  30. package/dist/development/route-inspector.d.ts +0 -211
  31. package/dist/development/typescript-utilities.d.ts +0 -209
  32. package/dist/docs.d.ts +0 -11
  33. package/dist/errors/circuit-breaker.d.ts +0 -195
  34. package/dist/errors/error-handler.d.ts +0 -88
  35. package/dist/errors/error-reporting.d.ts +0 -144
  36. package/dist/errors/exceptions.d.ts +0 -184
  37. package/dist/errors/graceful-degradation.d.ts +0 -154
  38. package/dist/errors/index.d.ts +0 -9
  39. package/dist/errors/router-errors.d.ts +0 -110
  40. package/dist/file-serving/static-files.d.ts +0 -143
  41. package/dist/index.d.ts +0 -14
  42. package/dist/index.js +0 -13933
  43. package/dist/middleware/auth.d.ts +0 -63
  44. package/dist/middleware/content_security_policy.d.ts +0 -53
  45. package/dist/middleware/cors.d.ts +0 -5
  46. package/dist/middleware/csrf.d.ts +0 -7
  47. package/dist/middleware/ddos_protection.d.ts +0 -39
  48. package/dist/middleware/file_security.d.ts +0 -26
  49. package/dist/middleware/file_upload.d.ts +0 -38
  50. package/dist/middleware/helmet.d.ts +0 -54
  51. package/dist/middleware/index.d.ts +0 -44
  52. package/dist/middleware/input_validation.d.ts +0 -45
  53. package/dist/middleware/json_body.d.ts +0 -4
  54. package/dist/middleware/performance_alerting.d.ts +0 -87
  55. package/dist/middleware/performance_dashboard.d.ts +0 -87
  56. package/dist/middleware/performance_monitor.d.ts +0 -209
  57. package/dist/middleware/pipeline.d.ts +0 -131
  58. package/dist/middleware/rate_limit.d.ts +0 -36
  59. package/dist/middleware/request_id.d.ts +0 -4
  60. package/dist/middleware/request_signing.d.ts +0 -153
  61. package/dist/middleware/request_tracer.d.ts +0 -72
  62. package/dist/middleware/response_cache.d.ts +0 -97
  63. package/dist/middleware/security.d.ts +0 -69
  64. package/dist/middleware/security_suite.d.ts +0 -46
  65. package/dist/middleware/session.d.ts +0 -23
  66. package/dist/model-binding/index.d.ts +0 -2
  67. package/dist/model-binding/model-middleware.d.ts +0 -118
  68. package/dist/model-binding/model-registry.d.ts +0 -164
  69. package/dist/model-binding.d.ts +0 -185
  70. package/dist/model-resolver-factory.d.ts +0 -31
  71. package/dist/observability/correlation.d.ts +0 -187
  72. package/dist/observability/health-checks.d.ts +0 -186
  73. package/dist/observability/index.d.ts +0 -60
  74. package/dist/observability/integration.d.ts +0 -147
  75. package/dist/observability/metrics.d.ts +0 -184
  76. package/dist/observability/tracing.d.ts +0 -187
  77. package/dist/optimization/bun-utilities.d.ts +0 -224
  78. package/dist/query-builder-integration.d.ts +0 -36
  79. package/dist/request/context.d.ts +0 -34
  80. package/dist/request/enhanced-request.d.ts +0 -213
  81. package/dist/request/macros.d.ts +0 -300
  82. package/dist/response/macros.d.ts +0 -245
  83. package/dist/response/response-factory.d.ts +0 -133
  84. package/dist/router/api-routes.d.ts +0 -5
  85. package/dist/router/file-based-routing.d.ts +0 -118
  86. package/dist/router/file-streaming.d.ts +0 -5
  87. package/dist/router/fluent-router.d.ts +0 -315
  88. package/dist/router/fluent-routing.d.ts +0 -271
  89. package/dist/router/group-organization.d.ts +0 -5
  90. package/dist/router/handler-resolver.d.ts +0 -24
  91. package/dist/router/http-methods.d.ts +0 -10
  92. package/dist/router/index.d.ts +0 -114
  93. package/dist/router/middleware-groups.d.ts +0 -94
  94. package/dist/router/middleware-integration.d.ts +0 -112
  95. package/dist/router/middleware.d.ts +0 -5
  96. package/dist/router/model-binding.d.ts +0 -5
  97. package/dist/router/optimized-route-matching.d.ts +0 -6
  98. package/dist/router/route-building.d.ts +0 -5
  99. package/dist/router/route-compiler.d.ts +0 -153
  100. package/dist/router/route-matching.d.ts +0 -5
  101. package/dist/router/route-trie.d.ts +0 -114
  102. package/dist/router/router.d.ts +0 -294
  103. package/dist/router/server.d.ts +0 -5
  104. package/dist/router/validation-integration.d.ts +0 -170
  105. package/dist/router/view-rendering.d.ts +0 -5
  106. package/dist/router/websocket.d.ts +0 -5
  107. package/dist/routing/route-caching.d.ts +0 -129
  108. package/dist/routing/route-throttling.d.ts +0 -150
  109. package/dist/routing/subdomain-routing.d.ts +0 -206
  110. package/dist/session/database-store.d.ts +0 -51
  111. package/dist/session/file-store.d.ts +0 -22
  112. package/dist/session/index.d.ts +0 -106
  113. package/dist/session/memory-store.d.ts +0 -21
  114. package/dist/session/redis-store.d.ts +0 -31
  115. package/dist/streaming/index.d.ts +0 -3
  116. package/dist/streaming/sse-handler.d.ts +0 -138
  117. package/dist/streaming/stream-handler.d.ts +0 -114
  118. package/dist/testing/auth-testing.d.ts +0 -156
  119. package/dist/testing/file-upload-testing.d.ts +0 -190
  120. package/dist/testing/index.d.ts +0 -10
  121. package/dist/testing/middleware-testing.d.ts +0 -138
  122. package/dist/testing/model-binding-testing.d.ts +0 -186
  123. package/dist/testing/performance-testing.d.ts +0 -235
  124. package/dist/testing/test-client.d.ts +0 -117
  125. package/dist/testing/test-request.d.ts +0 -85
  126. package/dist/testing/test-response.d.ts +0 -90
  127. package/dist/testing/types.d.ts +0 -207
  128. package/dist/testing/websocket-testing.d.ts +0 -227
  129. package/dist/types/controller-types.d.ts +0 -208
  130. package/dist/types/core.d.ts +0 -543
  131. package/dist/types/middleware-types.d.ts +0 -227
  132. package/dist/types/request-response-augmentation.d.ts +0 -261
  133. package/dist/types/route-inference.d.ts +0 -168
  134. package/dist/types.d.ts +0 -1782
  135. package/dist/url.d.ts +0 -56
  136. package/dist/utils/index.d.ts +0 -1
  137. package/dist/utils/query-preservation.d.ts +0 -48
  138. package/dist/utils.d.ts +0 -69
  139. package/dist/validation/validator.d.ts +0 -140
  140. package/dist/websocket/clustering.d.ts +0 -185
  141. package/src/auth.ts +0 -469
  142. package/src/cache/lru-cache.ts +0 -457
  143. package/src/cache/middleware-memoization.ts +0 -531
  144. package/src/cache/route-cache-warmer.ts +0 -486
  145. package/src/cache/sqlite-cache.ts +0 -783
  146. package/src/cache/streaming-cache.ts +0 -572
  147. package/src/cli/colors.ts +0 -29
  148. package/src/cli/index.ts +0 -287
  149. package/src/cli/middleware.ts +0 -291
  150. package/src/cli/openapi.ts +0 -407
  151. package/src/cli/router.ts +0 -188
  152. package/src/cli/routes.ts +0 -265
  153. package/src/cli/utils.ts +0 -531
  154. package/src/cli.ts +0 -5
  155. package/src/config.ts +0 -322
  156. package/src/container/container.ts +0 -740
  157. package/src/container/contextual-binding.ts +0 -603
  158. package/src/container/decorators.ts +0 -359
  159. package/src/container/service-provider.ts +0 -596
  160. package/src/development/hot-reload.ts +0 -673
  161. package/src/development/index.ts +0 -499
  162. package/src/development/performance-profiler.ts +0 -717
  163. package/src/development/route-debugger.ts +0 -527
  164. package/src/development/route-inspector.ts +0 -749
  165. package/src/development/typescript-utilities.ts +0 -682
  166. package/src/docs.ts +0 -397
  167. package/src/errors/circuit-breaker.ts +0 -732
  168. package/src/errors/error-handler.ts +0 -569
  169. package/src/errors/error-reporting.ts +0 -672
  170. package/src/errors/exceptions.ts +0 -536
  171. package/src/errors/graceful-degradation.ts +0 -621
  172. package/src/errors/index.ts +0 -21
  173. package/src/errors/router-errors.ts +0 -632
  174. package/src/file-serving/static-files.ts +0 -581
  175. package/src/index.ts +0 -14
  176. package/src/middleware/auth.ts +0 -219
  177. package/src/middleware/content_security_policy.ts +0 -215
  178. package/src/middleware/cors.ts +0 -74
  179. package/src/middleware/csrf.ts +0 -108
  180. package/src/middleware/ddos_protection.ts +0 -255
  181. package/src/middleware/file_security.ts +0 -191
  182. package/src/middleware/file_upload.ts +0 -264
  183. package/src/middleware/helmet.ts +0 -268
  184. package/src/middleware/index.ts +0 -117
  185. package/src/middleware/input_validation.ts +0 -449
  186. package/src/middleware/json_body.ts +0 -37
  187. package/src/middleware/performance_alerting.ts +0 -538
  188. package/src/middleware/performance_dashboard.ts +0 -661
  189. package/src/middleware/performance_monitor.ts +0 -943
  190. package/src/middleware/pipeline.ts +0 -489
  191. package/src/middleware/rate_limit.ts +0 -245
  192. package/src/middleware/request_id.ts +0 -36
  193. package/src/middleware/request_signing.ts +0 -636
  194. package/src/middleware/request_tracer.ts +0 -636
  195. package/src/middleware/response_cache.ts +0 -743
  196. package/src/middleware/security.ts +0 -482
  197. package/src/middleware/security_suite.ts +0 -257
  198. package/src/middleware/session.ts +0 -91
  199. package/src/model-binding/index.ts +0 -18
  200. package/src/model-binding/model-middleware.ts +0 -425
  201. package/src/model-binding/model-registry.ts +0 -550
  202. package/src/model-binding.ts +0 -370
  203. package/src/model-resolver-factory.ts +0 -106
  204. package/src/observability/correlation.ts +0 -691
  205. package/src/observability/health-checks.ts +0 -729
  206. package/src/observability/index.ts +0 -184
  207. package/src/observability/integration.ts +0 -548
  208. package/src/observability/metrics.ts +0 -753
  209. package/src/observability/tracing.ts +0 -638
  210. package/src/optimization/bun-utilities.ts +0 -778
  211. package/src/query-builder-integration.ts +0 -137
  212. package/src/request/context.ts +0 -62
  213. package/src/request/enhanced-request.ts +0 -857
  214. package/src/request/macros.ts +0 -688
  215. package/src/response/macros.ts +0 -612
  216. package/src/response/response-factory.ts +0 -596
  217. package/src/router/api-routes.ts +0 -243
  218. package/src/router/file-based-routing.ts +0 -670
  219. package/src/router/file-streaming.ts +0 -372
  220. package/src/router/fluent-router.ts +0 -927
  221. package/src/router/fluent-routing.ts +0 -797
  222. package/src/router/group-organization.ts +0 -213
  223. package/src/router/handler-resolver.ts +0 -291
  224. package/src/router/http-methods.ts +0 -377
  225. package/src/router/index.ts +0 -187
  226. package/src/router/middleware-groups.ts +0 -222
  227. package/src/router/middleware-integration.ts +0 -399
  228. package/src/router/middleware.ts +0 -231
  229. package/src/router/model-binding.ts +0 -215
  230. package/src/router/optimized-route-matching.ts +0 -253
  231. package/src/router/route-building.ts +0 -212
  232. package/src/router/route-compiler.ts +0 -702
  233. package/src/router/route-matching.ts +0 -349
  234. package/src/router/route-trie.ts +0 -464
  235. package/src/router/router.ts +0 -1581
  236. package/src/router/server.ts +0 -462
  237. package/src/router/validation-integration.ts +0 -443
  238. package/src/router/view-rendering.ts +0 -233
  239. package/src/router/websocket.ts +0 -100
  240. package/src/routing/route-caching.ts +0 -402
  241. package/src/routing/route-throttling.ts +0 -469
  242. package/src/routing/subdomain-routing.ts +0 -492
  243. package/src/session/database-store.ts +0 -109
  244. package/src/session/file-store.ts +0 -148
  245. package/src/session/index.ts +0 -244
  246. package/src/session/memory-store.ts +0 -88
  247. package/src/session/redis-store.ts +0 -93
  248. package/src/streaming/index.ts +0 -17
  249. package/src/streaming/sse-handler.ts +0 -482
  250. package/src/streaming/stream-handler.ts +0 -552
  251. package/src/testing/auth-testing.ts +0 -446
  252. package/src/testing/file-upload-testing.ts +0 -543
  253. package/src/testing/index.ts +0 -10
  254. package/src/testing/middleware-testing.ts +0 -322
  255. package/src/testing/model-binding-testing.ts +0 -645
  256. package/src/testing/performance-testing.ts +0 -738
  257. package/src/testing/test-client.ts +0 -310
  258. package/src/testing/test-request.ts +0 -315
  259. package/src/testing/test-response.ts +0 -332
  260. package/src/testing/types.ts +0 -224
  261. package/src/testing/websocket-testing.ts +0 -590
  262. package/src/types/controller-types.ts +0 -385
  263. package/src/types/core.ts +0 -683
  264. package/src/types/middleware-types.ts +0 -419
  265. package/src/types/request-response-augmentation.ts +0 -489
  266. package/src/types/route-inference.ts +0 -357
  267. package/src/types.ts +0 -2055
  268. package/src/url.ts +0 -126
  269. package/src/utils/index.ts +0 -1
  270. package/src/utils/query-preservation.ts +0 -201
  271. package/src/utils.ts +0 -327
  272. package/src/validation/validator.ts +0 -685
  273. 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.12",
5
- "description": "A fast, type-safe router for Bun.",
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": "bun --bun build.ts && bun run compile",
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
- "dependencies": {
87
- "@stacksjs/clapp": "^0.2.0",
88
- "bun-query-builder": "^0.1.13",
89
- "ts-rate-limiter": "^0.4.2"
74
+ "devDependencies": {
75
+ "@stacksjs/bunpress": "^0.1.4",
76
+ "better-dx": "^0.2.7"
90
77
  },
91
- "lint-staged": {
92
- "*.{js,ts}": "bunx --bun pickier . --fix"
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
@@ -1,9 +0,0 @@
1
- /**
2
- * This file is a simple entry point to the CLI implementation.
3
- * The actual CLI code is now modularized in src/cli/ directory.
4
- */
5
- import { createCLI } from '../src/cli/index'
6
-
7
- // Create and run the CLI
8
- const cli = createCLI()
9
- cli.parse()
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
- };