@stacksjs/bun-router 0.0.27 → 0.1.1

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 (108) hide show
  1. package/dist/chunk-03m2j6h7.js +2 -0
  2. package/dist/chunk-08cw7ejr.js +3 -0
  3. package/dist/chunk-0e4g0fyv.js +62 -0
  4. package/dist/chunk-0mmn02yw.js +2 -0
  5. package/dist/chunk-126c9qm3.js +2 -0
  6. package/dist/chunk-12p13817.js +2 -0
  7. package/dist/chunk-14v65c37.js +4 -0
  8. package/dist/chunk-1b6a7t3v.js +231 -0
  9. package/dist/chunk-1wenkmk0.js +2 -0
  10. package/dist/chunk-2152npfd.js +2 -0
  11. package/dist/chunk-26w23krx.js +2 -0
  12. package/dist/chunk-2g8m379z.js +10 -0
  13. package/dist/chunk-2rr178et.js +1654 -0
  14. package/dist/chunk-2w8f3swz.js +29 -0
  15. package/dist/chunk-3y4gaz7v.js +82 -0
  16. package/dist/chunk-4r1x4afz.js +12 -0
  17. package/dist/chunk-4wyw66zk.js +2 -0
  18. package/dist/chunk-4z5sf8ag.js +2 -0
  19. package/dist/chunk-58tfvayh.js +4 -0
  20. package/dist/chunk-5be9x5cq.js +3 -0
  21. package/dist/chunk-5dp83qcx.js +397 -0
  22. package/dist/chunk-5f0d9j9a.js +2 -0
  23. package/dist/chunk-5z52b0fc.js +28 -0
  24. package/dist/chunk-5zrnk2kq.js +4 -0
  25. package/dist/chunk-6bbmkwng.js +3 -0
  26. package/dist/chunk-6dmqtdnq.js +2 -0
  27. package/dist/chunk-6e91956t.js +3 -0
  28. package/dist/chunk-6rv8w5jk.js +2 -0
  29. package/dist/chunk-6x1feysm.js +3 -0
  30. package/dist/chunk-7qnxdedn.js +321 -0
  31. package/dist/chunk-7y72hm1x.js +2 -0
  32. package/dist/chunk-8hbhfh6b.js +194 -0
  33. package/dist/chunk-8kfzygg5.js +3 -0
  34. package/dist/chunk-8wpj3fqe.js +351 -0
  35. package/dist/chunk-8wydx2we.js +2 -0
  36. package/dist/chunk-8zjnjvv7.js +2 -0
  37. package/dist/chunk-9805tt8n.js +341 -0
  38. package/dist/chunk-988h4bzr.js +2 -0
  39. package/dist/chunk-9b6a58ac.js +2 -0
  40. package/dist/chunk-a8fcaywb.js +2 -0
  41. package/dist/chunk-bfjwn7yg.js +2 -0
  42. package/dist/chunk-bp2522mm.js +2 -0
  43. package/dist/chunk-brpgjyqg.js +3 -0
  44. package/dist/chunk-bswe62q4.js +48 -0
  45. package/dist/chunk-c3v796c8.js +943 -0
  46. package/dist/chunk-ccqmwdry.js +2 -0
  47. package/dist/chunk-ck0crwnx.js +2 -0
  48. package/dist/chunk-cqgkxcb4.js +2 -0
  49. package/dist/chunk-dntnakjy.js +2 -0
  50. package/dist/chunk-dxg045wj.js +5 -0
  51. package/dist/chunk-e3qej0jr.js +4 -0
  52. package/dist/chunk-ettdpnrw.js +60 -0
  53. package/dist/chunk-ezqwq17j.js +185 -0
  54. package/dist/chunk-ezx3qsez.js +2 -0
  55. package/dist/chunk-f72nnjy4.js +15413 -0
  56. package/dist/chunk-fna5n0ey.js +246 -0
  57. package/dist/chunk-fqhckdt8.js +2 -0
  58. package/dist/chunk-fr6hbx25.js +2 -0
  59. package/dist/chunk-g9cwng6w.js +3 -0
  60. package/dist/chunk-gd3za5x0.js +2 -0
  61. package/dist/chunk-gf28608k.js +2 -0
  62. package/dist/chunk-h1dj6v8q.js +3 -0
  63. package/dist/chunk-hjxe7k2g.js +2 -0
  64. package/dist/chunk-hrkgznbn.js +2 -0
  65. package/dist/chunk-j6h5v0br.js +2 -0
  66. package/dist/chunk-kjtjbcq4.js +71 -0
  67. package/dist/chunk-mgb01qdv.js +14 -0
  68. package/dist/chunk-n24c9whp.js +2 -0
  69. package/dist/chunk-n2j24b0h.js +4540 -0
  70. package/dist/chunk-nf3kv7kv.js +3 -0
  71. package/dist/chunk-nhmtg01n.js +84 -0
  72. package/dist/chunk-p0qhpnqh.js +70 -0
  73. package/dist/chunk-p0w1x8y2.js +3 -0
  74. package/dist/chunk-p3dk1w2w.js +216 -0
  75. package/dist/chunk-q4e9pxs7.js +3 -0
  76. package/dist/chunk-q5dv1kyy.js +2 -0
  77. package/dist/chunk-qnqgf9tq.js +2 -0
  78. package/dist/chunk-qvwy1808.js +898 -0
  79. package/dist/chunk-r18f77vc.js +12 -0
  80. package/dist/chunk-r63za1mr.js +2 -0
  81. package/dist/chunk-rft8gw92.js +7851 -0
  82. package/dist/chunk-ryvmyskt.js +4211 -0
  83. package/dist/chunk-sa6mx308.js +2 -0
  84. package/dist/chunk-sw0chtw4.js +4 -0
  85. package/dist/chunk-va0pc7hx.js +2 -0
  86. package/dist/chunk-vcp8dnjq.js +412 -0
  87. package/dist/chunk-vg1erq1q.js +2 -0
  88. package/dist/chunk-vsh4390q.js +358 -0
  89. package/dist/chunk-w0jv49ch.js +11 -0
  90. package/dist/chunk-wm805tte.js +35 -0
  91. package/dist/chunk-xg9xscqz.js +1 -0
  92. package/dist/chunk-xj9h6mc9.js +2 -0
  93. package/dist/chunk-ytvzwrq3.js +51 -0
  94. package/dist/chunk-zde7ebc4.js +288 -0
  95. package/dist/chunk-zmqsv2xy.js +2 -0
  96. package/dist/cli.js +51 -3233
  97. package/dist/container/index.js +1 -321
  98. package/dist/index.d.ts +1 -0
  99. package/dist/index.js +80 -13987
  100. package/dist/typed/client.d.ts +89 -0
  101. package/dist/typed/contract.d.ts +34 -0
  102. package/dist/typed/endpoint.d.ts +90 -0
  103. package/dist/typed/index.d.ts +14 -0
  104. package/dist/typed/router.d.ts +141 -0
  105. package/package.json +1 -1
  106. package/dist/chunk-1ahs68ys.js +0 -18
  107. package/dist/chunk-cgptvjdf.js +0 -18131
  108. package/dist/chunk-g3ybefhg.js +0 -1923
@@ -1,322 +1,2 @@
1
1
  // @bun
2
- import {
3
- AuthGuard,
4
- AuthService,
5
- AuthServiceProvider,
6
- BaseDeferredServiceProvider,
7
- BaseServiceProvider,
8
- BindingBuilder,
9
- BindingConditions,
10
- CacheManager,
11
- CacheServiceProvider,
12
- ConfigService,
13
- ConfigServiceProvider,
14
- ConsoleLogger,
15
- Container,
16
- ContextualContainer,
17
- DatabaseConnection,
18
- DatabaseServiceProvider,
19
- DefaultContextualBindingBuilder,
20
- DefaultServiceProviderManager,
21
- EnvironmentManager,
22
- EnvironmentPresets,
23
- EventBus,
24
- EventDispatcher,
25
- EventServiceProvider,
26
- FileLogger,
27
- INJECTABLE_METADATA_KEY,
28
- INJECT_METADATA_KEY,
29
- JwtService,
30
- Logger,
31
- LoggingServiceProvider,
32
- MemoryCache,
33
- OPTIONAL_METADATA_KEY,
34
- PostRepository,
35
- RedisCache,
36
- TAGGED_METADATA_KEY,
37
- UserRepository,
38
- ValidationPipe,
39
- ValidationServiceProvider,
40
- Validator,
41
- createContainer,
42
- getContainer,
43
- setContainer
44
- } from "../chunk-g3ybefhg.js";
45
- import"../chunk-1ahs68ys.js";
46
- // src/container/decorators.ts
47
- var CONTROLLER_METADATA_KEY = Symbol("controller");
48
- var ROUTE_METADATA_KEY = Symbol("route");
49
- var MIDDLEWARE_METADATA_KEY = Symbol("middleware");
50
- var PARAM_METADATA_KEY = Symbol("param");
51
- function Injectable(metadata = {}) {
52
- return (target) => {
53
- target[INJECTABLE_METADATA_KEY] = metadata;
54
- return target;
55
- };
56
- }
57
- function Inject(token, options) {
58
- return function(target, _propertyKey, parameterIndex) {
59
- const classConstructor = target.constructor === Function ? target : target.constructor;
60
- if (!classConstructor[INJECT_METADATA_KEY]) {
61
- classConstructor[INJECT_METADATA_KEY] = [];
62
- }
63
- const metadata = {
64
- token,
65
- optional: options?.optional,
66
- tags: options?.tags,
67
- when: options?.when
68
- };
69
- classConstructor[INJECT_METADATA_KEY][parameterIndex] = metadata;
70
- };
71
- }
72
- function Optional() {
73
- return (target, _propertyKey, parameterIndex) => {
74
- if (!target[OPTIONAL_METADATA_KEY]) {
75
- target[OPTIONAL_METADATA_KEY] = [];
76
- }
77
- target[OPTIONAL_METADATA_KEY][parameterIndex] = true;
78
- };
79
- }
80
- function Tagged(tag) {
81
- return function(target, _propertyKey, parameterIndex) {
82
- if (!target[TAGGED_METADATA_KEY]) {
83
- target[TAGGED_METADATA_KEY] = [];
84
- }
85
- target[TAGGED_METADATA_KEY][parameterIndex] = tag;
86
- };
87
- }
88
- function Controller(prefix, options) {
89
- return function(target) {
90
- const metadata = {
91
- prefix: prefix || "",
92
- middleware: options?.middleware || [],
93
- tags: options?.tags || []
94
- };
95
- target[CONTROLLER_METADATA_KEY] = metadata;
96
- return target;
97
- };
98
- }
99
- function Get(path = "", options) {
100
- return createRouteDecorator("GET", path, options);
101
- }
102
- function Post(path = "", options) {
103
- return createRouteDecorator("POST", path, options);
104
- }
105
- function Put(path = "", options) {
106
- return createRouteDecorator("PUT", path, options);
107
- }
108
- function Delete(path = "", options) {
109
- return createRouteDecorator("DELETE", path, options);
110
- }
111
- function Patch(path = "", options) {
112
- return createRouteDecorator("PATCH", path, options);
113
- }
114
- function Options(path = "", options) {
115
- return createRouteDecorator("OPTIONS", path, options);
116
- }
117
- function Head(path = "", options) {
118
- return createRouteDecorator("HEAD", path, options);
119
- }
120
- function createRouteDecorator(method, path, options) {
121
- return function(target, propertyKey, descriptor) {
122
- if (!target.constructor[ROUTE_METADATA_KEY]) {
123
- target.constructor[ROUTE_METADATA_KEY] = [];
124
- }
125
- const metadata = {
126
- method,
127
- path,
128
- middleware: options?.middleware || [],
129
- tags: options?.tags || []
130
- };
131
- target.constructor[ROUTE_METADATA_KEY].push({
132
- ...metadata,
133
- propertyKey,
134
- handler: descriptor.value
135
- });
136
- return descriptor;
137
- };
138
- }
139
- function UseMiddleware(...middleware) {
140
- return function(target, propertyKey, descriptor) {
141
- if (propertyKey && descriptor) {
142
- if (!target.constructor[MIDDLEWARE_METADATA_KEY]) {
143
- target.constructor[MIDDLEWARE_METADATA_KEY] = new Map;
144
- }
145
- target.constructor[MIDDLEWARE_METADATA_KEY].set(propertyKey, middleware);
146
- } else {
147
- target[MIDDLEWARE_METADATA_KEY] = middleware;
148
- }
149
- return descriptor || target;
150
- };
151
- }
152
- function Param(key) {
153
- return createParamDecorator("param", key);
154
- }
155
- function Query(key) {
156
- return createParamDecorator("query", key);
157
- }
158
- function Body() {
159
- return createParamDecorator("body");
160
- }
161
- function Header(key) {
162
- return createParamDecorator("header", key);
163
- }
164
- function Cookie(key) {
165
- return createParamDecorator("cookie", key);
166
- }
167
- function InjectParam(token) {
168
- return createParamDecorator("param", undefined, token);
169
- }
170
- function createParamDecorator(type, key, token) {
171
- return function(target, propertyKey, parameterIndex) {
172
- if (!target.constructor[PARAM_METADATA_KEY]) {
173
- target.constructor[PARAM_METADATA_KEY] = new Map;
174
- }
175
- if (!target.constructor[PARAM_METADATA_KEY].has(propertyKey)) {
176
- target.constructor[PARAM_METADATA_KEY].set(propertyKey, []);
177
- }
178
- const metadata = {
179
- type,
180
- key,
181
- token
182
- };
183
- target.constructor[PARAM_METADATA_KEY].get(propertyKey)[parameterIndex] = metadata;
184
- };
185
- }
186
-
187
- class MetadataReader {
188
- static getInjectableMetadata(target) {
189
- return target[INJECTABLE_METADATA_KEY];
190
- }
191
- static getInjectMetadata(target) {
192
- return target[INJECT_METADATA_KEY] || [];
193
- }
194
- static getOptionalMetadata(target) {
195
- return target[OPTIONAL_METADATA_KEY] || [];
196
- }
197
- static getTaggedMetadata(target) {
198
- return target[TAGGED_METADATA_KEY] || [];
199
- }
200
- static getControllerMetadata(target) {
201
- return target[CONTROLLER_METADATA_KEY];
202
- }
203
- static getAllRoutes(target) {
204
- return target[ROUTE_METADATA_KEY] || [];
205
- }
206
- static getMiddlewareMetadata(target, propertyKey) {
207
- if (propertyKey) {
208
- const methodMiddleware = target[MIDDLEWARE_METADATA_KEY]?.get(propertyKey);
209
- return methodMiddleware || [];
210
- }
211
- return target[MIDDLEWARE_METADATA_KEY] || [];
212
- }
213
- static getParamMetadata(target, propertyKey) {
214
- return target[PARAM_METADATA_KEY]?.get(propertyKey) || [];
215
- }
216
- }
217
-
218
- class DecoratorContainer extends Container {
219
- registerController(controllerClass) {
220
- const metadata = MetadataReader.getControllerMetadata(controllerClass);
221
- if (!metadata) {
222
- throw new Error(`Class ${controllerClass.name} is not decorated with @Controller`);
223
- }
224
- this.singleton(controllerClass, controllerClass);
225
- const routes = MetadataReader.getAllRoutes(controllerClass);
226
- for (const _route of routes) {}
227
- }
228
- resolve(token, context) {
229
- if (typeof token === "function") {
230
- const metadata = MetadataReader.getInjectableMetadata(token);
231
- if (metadata) {
232
- try {
233
- return super.resolve(token, context);
234
- } catch {
235
- const scope = metadata.scope || "transient";
236
- switch (scope) {
237
- case "singleton":
238
- this.singleton(token, token);
239
- break;
240
- case "transient":
241
- this.transient(token, token);
242
- break;
243
- default:
244
- this.transient(token, token);
245
- }
246
- }
247
- }
248
- }
249
- return super.resolve(token, context);
250
- }
251
- }
252
- var decoratorContainer = new DecoratorContainer;
253
- export {
254
- setContainer,
255
- getContainer,
256
- decoratorContainer,
257
- createContainer,
258
- Validator,
259
- ValidationServiceProvider,
260
- ValidationPipe,
261
- UserRepository,
262
- UseMiddleware,
263
- Tagged,
264
- TAGGED_METADATA_KEY,
265
- RedisCache,
266
- ROUTE_METADATA_KEY,
267
- Query,
268
- Put,
269
- PostRepository,
270
- Post,
271
- Patch,
272
- Param,
273
- PARAM_METADATA_KEY,
274
- Options,
275
- Optional,
276
- OPTIONAL_METADATA_KEY,
277
- MetadataReader,
278
- MemoryCache,
279
- MIDDLEWARE_METADATA_KEY,
280
- LoggingServiceProvider,
281
- Logger,
282
- JwtService,
283
- Injectable,
284
- InjectParam,
285
- Inject,
286
- INJECT_METADATA_KEY,
287
- INJECTABLE_METADATA_KEY,
288
- Header,
289
- Head,
290
- Get,
291
- FileLogger,
292
- EventServiceProvider,
293
- EventDispatcher,
294
- EventBus,
295
- EnvironmentPresets,
296
- EnvironmentManager,
297
- Delete,
298
- DefaultServiceProviderManager,
299
- DefaultContextualBindingBuilder,
300
- DecoratorContainer,
301
- DatabaseServiceProvider,
302
- DatabaseConnection,
303
- Container as DIContainer,
304
- Cookie,
305
- Controller,
306
- ContextualContainer,
307
- Container,
308
- ConsoleLogger,
309
- ConfigServiceProvider,
310
- ConfigService,
311
- CacheServiceProvider,
312
- CacheManager,
313
- CONTROLLER_METADATA_KEY,
314
- Body,
315
- BindingConditions,
316
- BindingBuilder,
317
- BaseServiceProvider,
318
- BaseDeferredServiceProvider,
319
- AuthServiceProvider,
320
- AuthService,
321
- AuthGuard
322
- };
2
+ import{$r as wt,Ar as Z,Br as tt,Cr as et,Dr as nt,Er as rt,Fr as ot,Gr as at,Hr as it,Ir as st,Jr as ct,Kr as ut,Lr as dt,Mr as lt,Nr as mt,Or as gt,Pr as pt,Qr as ft,Rr as yt,Sr as Mt,Tr as At,Ur as Dt,Vr as bt,Wr as xt,Xr as Tt,Yr as Et,Zr as Pt,_r as ht,as as Ft,bs as _t,cs as Ct,qr as y,rr as l,sr as m,tr as g,ur as D,vr as Q,wr as W,xr as z,yr as V,zr as X}from"../chunk-3y4gaz7v.js";import"../chunk-nf3kv7kv.js";var M=Symbol("controller"),p=Symbol("route"),s=Symbol("middleware"),i=Symbol("param");function b(t={}){return(e)=>(e[y]=t,e)}function x(t,e){return function(n,r,a){let o=n.constructor===Function?n:n.constructor;if(!o[l])o[l]=[];let d={token:t,optional:e?.optional,tags:e?.tags,when:e?.when};o[l][a]=d}}function T(){return(t,e,n)=>{if(!t[m])t[m]=[];t[m][n]=!0}}function E(t){return function(e,n,r){if(!e[g])e[g]=[];e[g][r]=t}}function P(t,e){return function(n){let r={prefix:t||"",middleware:e?.middleware||[],tags:e?.tags||[]};return n[M]=r,n}}function h(t="",e){return c("GET",t,e)}function w(t="",e){return c("POST",t,e)}function F(t="",e){return c("PUT",t,e)}function _(t="",e){return c("DELETE",t,e)}function C(t="",e){return c("PATCH",t,e)}function I(t="",e){return c("OPTIONS",t,e)}function R(t="",e){return c("HEAD",t,e)}function c(t,e,n){return function(r,a,o){if(!r.constructor[p])r.constructor[p]=[];let d={method:t,path:e,middleware:n?.middleware||[],tags:n?.tags||[]};return r.constructor[p].push({...d,propertyKey:a,handler:o.value}),o}}function O(...t){return function(e,n,r){if(n&&r){if(!e.constructor[s])e.constructor[s]=new Map;e.constructor[s].set(n,t)}else e[s]=t;return r||e}}function j(t){return u("param",t)}function Y(t){return u("query",t)}function K(){return u("body")}function L(t){return u("header",t)}function q(t){return u("cookie",t)}function v(t){return u("param",void 0,t)}function u(t,e,n){return function(r,a,o){if(!r.constructor[i])r.constructor[i]=new Map;if(!r.constructor[i].has(a))r.constructor[i].set(a,[]);let d={type:t,key:e,token:n};r.constructor[i].get(a)[o]=d}}class f{static getInjectableMetadata(t){return t[y]}static getInjectMetadata(t){return t[l]||[]}static getOptionalMetadata(t){return t[m]||[]}static getTaggedMetadata(t){return t[g]||[]}static getControllerMetadata(t){return t[M]}static getAllRoutes(t){return t[p]||[]}static getMiddlewareMetadata(t,e){if(e)return t[s]?.get(e)||[];return t[s]||[]}static getParamMetadata(t,e){return t[i]?.get(e)||[]}}class A extends D{registerController(t){if(!f.getControllerMetadata(t))throw Error(`Class ${t.name} is not decorated with @Controller`);this.singleton(t,t);let n=f.getAllRoutes(t);for(let r of n);}resolve(t,e){if(typeof t==="function"){let n=f.getInjectableMetadata(t);if(n)try{return super.resolve(t,e)}catch{switch(n.scope||"transient"){case"singleton":this.singleton(t,t);break;case"transient":this.transient(t,t);break;default:this.transient(t,t)}}}return super.resolve(t,e)}}var H=new A;export{ht as AuthGuard,Et as AuthService,dt as AuthServiceProvider,ot as BaseDeferredServiceProvider,rt as BaseServiceProvider,Q as BindingBuilder,nt as BindingConditions,K as Body,M as CONTROLLER_METADATA_KEY,bt as CacheManager,ut as CacheServiceProvider,gt as ConfigService,it as ConfigServiceProvider,ft as ConsoleLogger,D as Container,tt as ContextualContainer,P as Controller,q as Cookie,D as DIContainer,Mt as DatabaseConnection,ct as DatabaseServiceProvider,A as DecoratorContainer,Z as DefaultContextualBindingBuilder,at as DefaultServiceProviderManager,_ as Delete,X as EnvironmentManager,et as EnvironmentPresets,_t as EventBus,Ct as EventDispatcher,mt as EventServiceProvider,yt as FileLogger,h as Get,R as Head,L as Header,y as INJECTABLE_METADATA_KEY,l as INJECT_METADATA_KEY,x as Inject,v as InjectParam,b as Injectable,Pt as JwtService,pt as Logger,st as LoggingServiceProvider,s as MIDDLEWARE_METADATA_KEY,xt as MemoryCache,f as MetadataReader,m as OPTIONAL_METADATA_KEY,T as Optional,I as Options,i as PARAM_METADATA_KEY,j as Param,C as Patch,w as Post,Dt as PostRepository,F as Put,Y as Query,p as ROUTE_METADATA_KEY,Tt as RedisCache,g as TAGGED_METADATA_KEY,E as Tagged,O as UseMiddleware,At as UserRepository,Ft as ValidationPipe,lt as ValidationServiceProvider,wt as Validator,V as createContainer,H as decoratorContainer,W as getContainer,z as setContainer};
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export * from './response/response-factory';
25
25
  export * from './router';
26
26
  export { MiddlewareGroupRegistry, middlewareGroups } from './router/middleware-groups';
27
27
  export * from './testing';
28
+ export * from './typed';
28
29
  export * from './types';
29
30
  export * from './validation/validator';
30
31
  export { clearNamedRoutes, getNamedRoutePath, getNamedRoutes, registerNamedRoute, url, type UrlOptions } from './url';