@stacksjs/bun-router 0.1.7 → 0.1.9
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-7g1et0fb.js +82 -0
- package/dist/chunk-9y37n6xs.js +61 -0
- package/dist/chunk-trm3jyqk.js +357 -0
- package/dist/cli.js +30 -59
- package/dist/container/index.js +1 -1
- package/dist/index.js +29 -29
- package/dist/middleware/rate_limit.d.ts +2 -1
- package/dist/response/compression.d.ts +6 -0
- package/package.json +10 -2
- package/dist/chunk-03m2j6h7.js +0 -2
- package/dist/chunk-08cw7ejr.js +0 -3
- package/dist/chunk-0e4g0fyv.js +0 -62
- package/dist/chunk-0mmn02yw.js +0 -2
- package/dist/chunk-126c9qm3.js +0 -2
- package/dist/chunk-12p13817.js +0 -2
- package/dist/chunk-14v65c37.js +0 -4
- package/dist/chunk-1b6a7t3v.js +0 -231
- package/dist/chunk-1wenkmk0.js +0 -2
- package/dist/chunk-2152npfd.js +0 -2
- package/dist/chunk-26w23krx.js +0 -2
- package/dist/chunk-2g8m379z.js +0 -10
- package/dist/chunk-2rr178et.js +0 -1654
- package/dist/chunk-2w8f3swz.js +0 -29
- package/dist/chunk-3y4gaz7v.js +0 -82
- package/dist/chunk-4r1x4afz.js +0 -12
- package/dist/chunk-4wyw66zk.js +0 -2
- package/dist/chunk-4z5sf8ag.js +0 -2
- package/dist/chunk-58tfvayh.js +0 -4
- package/dist/chunk-5be9x5cq.js +0 -3
- package/dist/chunk-5dp83qcx.js +0 -397
- package/dist/chunk-5f0d9j9a.js +0 -2
- package/dist/chunk-5z52b0fc.js +0 -28
- package/dist/chunk-5zrnk2kq.js +0 -4
- package/dist/chunk-6bbmkwng.js +0 -3
- package/dist/chunk-6dmqtdnq.js +0 -2
- package/dist/chunk-6e91956t.js +0 -3
- package/dist/chunk-6rv8w5jk.js +0 -2
- package/dist/chunk-6x1feysm.js +0 -3
- package/dist/chunk-7qnxdedn.js +0 -321
- package/dist/chunk-7y72hm1x.js +0 -2
- package/dist/chunk-8hbhfh6b.js +0 -194
- package/dist/chunk-8kfzygg5.js +0 -3
- package/dist/chunk-8wpj3fqe.js +0 -351
- package/dist/chunk-8wydx2we.js +0 -2
- package/dist/chunk-8zjnjvv7.js +0 -2
- package/dist/chunk-9805tt8n.js +0 -341
- package/dist/chunk-988h4bzr.js +0 -2
- package/dist/chunk-9b6a58ac.js +0 -2
- package/dist/chunk-a8fcaywb.js +0 -2
- package/dist/chunk-bfjwn7yg.js +0 -2
- package/dist/chunk-bp2522mm.js +0 -2
- package/dist/chunk-brpgjyqg.js +0 -3
- package/dist/chunk-bswe62q4.js +0 -48
- package/dist/chunk-c3v796c8.js +0 -943
- package/dist/chunk-ccqmwdry.js +0 -2
- package/dist/chunk-ck0crwnx.js +0 -2
- package/dist/chunk-cqgkxcb4.js +0 -2
- package/dist/chunk-dntnakjy.js +0 -2
- package/dist/chunk-dxg045wj.js +0 -5
- package/dist/chunk-e3qej0jr.js +0 -4
- package/dist/chunk-ettdpnrw.js +0 -60
- package/dist/chunk-ezqwq17j.js +0 -185
- package/dist/chunk-ezx3qsez.js +0 -2
- package/dist/chunk-f72nnjy4.js +0 -15413
- package/dist/chunk-fna5n0ey.js +0 -246
- package/dist/chunk-fqhckdt8.js +0 -2
- package/dist/chunk-fr6hbx25.js +0 -2
- package/dist/chunk-g9cwng6w.js +0 -3
- package/dist/chunk-gd3za5x0.js +0 -2
- package/dist/chunk-gf28608k.js +0 -2
- package/dist/chunk-h1dj6v8q.js +0 -3
- package/dist/chunk-hjxe7k2g.js +0 -2
- package/dist/chunk-hrkgznbn.js +0 -2
- package/dist/chunk-j6h5v0br.js +0 -2
- package/dist/chunk-kjtjbcq4.js +0 -71
- package/dist/chunk-mgb01qdv.js +0 -14
- package/dist/chunk-n24c9whp.js +0 -2
- package/dist/chunk-n2j24b0h.js +0 -4540
- package/dist/chunk-nf3kv7kv.js +0 -3
- package/dist/chunk-nhmtg01n.js +0 -84
- package/dist/chunk-p0qhpnqh.js +0 -70
- package/dist/chunk-p0w1x8y2.js +0 -3
- package/dist/chunk-p3dk1w2w.js +0 -216
- package/dist/chunk-q4e9pxs7.js +0 -3
- package/dist/chunk-q5dv1kyy.js +0 -2
- package/dist/chunk-qnqgf9tq.js +0 -2
- package/dist/chunk-qvwy1808.js +0 -898
- package/dist/chunk-r18f77vc.js +0 -12
- package/dist/chunk-r63za1mr.js +0 -2
- package/dist/chunk-rft8gw92.js +0 -7851
- package/dist/chunk-ryvmyskt.js +0 -4211
- package/dist/chunk-sa6mx308.js +0 -2
- package/dist/chunk-sw0chtw4.js +0 -4
- package/dist/chunk-va0pc7hx.js +0 -2
- package/dist/chunk-vcp8dnjq.js +0 -412
- package/dist/chunk-vg1erq1q.js +0 -2
- package/dist/chunk-vsh4390q.js +0 -358
- package/dist/chunk-w0jv49ch.js +0 -11
- package/dist/chunk-wm805tte.js +0 -35
- package/dist/chunk-xg9xscqz.js +0 -1
- package/dist/chunk-xj9h6mc9.js +0 -2
- package/dist/chunk-ytvzwrq3.js +0 -51
- package/dist/chunk-zde7ebc4.js +0 -288
- package/dist/chunk-zmqsv2xy.js +0 -2
|
@@ -32,9 +32,10 @@ export interface RateLimitOptions {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
export default class RateLimit implements Middleware {
|
|
35
|
-
private
|
|
35
|
+
private limiterPromise?;
|
|
36
36
|
private options;
|
|
37
37
|
constructor(options?: RateLimitOptions);
|
|
38
|
+
private getLimiter;
|
|
38
39
|
private initLimiter;
|
|
39
40
|
private defaultHandler;
|
|
40
41
|
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
@@ -84,6 +84,12 @@ export declare function shouldCompress(response: Response, encoding: string | nu
|
|
|
84
84
|
* Returns the response it was given when it is not, so a caller can apply this
|
|
85
85
|
* unconditionally at the end of the pipeline.
|
|
86
86
|
*/
|
|
87
|
+
export declare function applyResponseCompression(response: Response, request: Request, options?: CompressionOptions): Response | Promise<Response>;
|
|
88
|
+
/**
|
|
89
|
+
* Preserve the original Promise-only public contract for direct callers.
|
|
90
|
+
* The server uses `applyResponseCompression` so the usual uncompressed and
|
|
91
|
+
* known-length paths do not create a second promise per request.
|
|
92
|
+
*/
|
|
87
93
|
export declare function compressResponse(response: Response, request: Request, options?: CompressionOptions): Promise<Response>;
|
|
88
94
|
/**
|
|
89
95
|
* Read up to `limit` bytes, and hand back a stream that still has them.
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/bun-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.9",
|
|
5
5
|
"description": "A fast, type-safe router for Bun.",
|
|
6
|
-
"author": "Chris Breuer <chris@stacksjs.
|
|
6
|
+
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/stacksjs/bun-router#readme",
|
|
9
9
|
"repository": {
|
|
@@ -95,5 +95,13 @@
|
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@stacksjs/clapp": "^0.2.0",
|
|
97
97
|
"ts-rate-limiter": "^0.4.2"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"@stacksjs/stx": ">=0.2.227"
|
|
101
|
+
},
|
|
102
|
+
"peerDependenciesMeta": {
|
|
103
|
+
"@stacksjs/stx": {
|
|
104
|
+
"optional": true
|
|
105
|
+
}
|
|
98
106
|
}
|
|
99
107
|
}
|
package/dist/chunk-03m2j6h7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Pe as a,Qe as b,Re as c,Se as d,Te as e,Ue as f,Ve as g}from"./chunk-8wpj3fqe.js";import"./chunk-nf3kv7kv.js";export{b as createKeepAliveCache,d as generateKeepAliveCSS,e as generateKeepAliveRuntime,f as onActivated,g as onDeactivated,a as processKeepAliveDirectives,c as shouldCacheComponent};
|
package/dist/chunk-08cw7ejr.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{qs as F}from"./chunk-h1dj6v8q.js";import{Zu as C}from"./chunk-nf3kv7kv.js";import v from"fs";import d from"path";import A from"crypto";var R=new Set(["webp","avif","jpeg","png"]),S=new Set(["cover","contain","fill","inside","outside"]),D=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"]),k=4096,U=80,N="cover";async function L(e,t){let a=t.routePath??"/_stx/img",p=new URL(e.url);if(p.pathname!==a)return null;let s=M(p,t);if(!s.ok)return new Response(s.error,{status:s.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:i,srcUrl:g,width:l,height:n,format:r,quality:c,fit:h}=s,m;try{m=v.statSync(i)}catch{return new Response(`Source image not found: ${g}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!m.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let w=t.cacheDir??".stx/cache/img";await v.promises.mkdir(w,{recursive:!0});let b=`${i}:${m.mtimeMs}:${m.size}`,x=`${l}x${n}:${r}:${c}:${h}`,f=A.createHash("sha256").update(`${b}|${x}`).digest("hex").slice(0,16),o=d.join(w,`${f}.${r}`),u={"Content-Type":F(r),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${f}"`,"X-Stx-Image-Cache":"HIT"};if(e.headers.get("if-none-match")===`"${f}"`)return new Response(null,{status:304,headers:u});let T=Bun.file(o);if(await T.exists())return new Response(T,{headers:u});try{let y=Buffer.from(await Bun.file(i).arrayBuffer()),{resizeAndConvert:I}=await q(),P=await I(y,{width:l,height:n,format:r,quality:c,fit:h});return await Bun.write(o,P),u["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(P),{headers:u})}catch(y){let I=y.message;return new Response(`Image processing failed: ${I}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function H(e){return async(t)=>await L(t,e)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}function M(e,t){let a=e.searchParams.get("src");if(!a)return{ok:!1,error:"Missing required param: src",status:400};if(!a.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(a.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let p=d.extname(a).toLowerCase();if(!D.has(p))return{ok:!1,error:`Unsupported source extension: ${p}`,status:400};let s=d.resolve(t.publicDir),i=d.resolve(s,a.slice(1));if(!i.startsWith(`${s}${d.sep}`)&&i!==s)return{ok:!1,error:"src is outside publicDir",status:400};let g=t.maxWidth??k,l=t.maxHeight??k,n=e.searchParams.get("w"),r=e.searchParams.get("h"),c=n?Number.parseInt(n,10):0,h=r?Number.parseInt(r,10):0;if(n&&(!Number.isFinite(c)||c<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(r&&(!Number.isFinite(h)||h<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!n&&!r)return{ok:!1,error:"At least one of w or h is required",status:400};let m=Math.min(c||g,g),w=Math.min(h||l,l),b=e.searchParams.get("f")||"webp";if(!R.has(b))return{ok:!1,error:`Invalid f (must be one of: ${[...R].join(", ")})`,status:400};let x=b,f=e.searchParams.get("q"),o=f?Number.parseInt(f,10):t.defaultQuality??U;if(!Number.isFinite(o)||o<1||o>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let u=e.searchParams.get("fit")||t.defaultFit||N;if(!S.has(u))return{ok:!1,error:`Invalid fit (must be one of: ${[...S].join(", ")})`,status:400};return{ok:!0,srcFsPath:i,srcUrl:a,width:m,height:w,format:x,quality:o,fit:u}}async function q(){return await import("./chunk-cqgkxcb4.js")}
|
|
3
|
-
export{L as m,H as n};
|