Socket
Socket
Sign inDemoInstall

itty-router

Package Overview
Dependencies
0
Maintainers
2
Versions
264
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.0-next.1 to 4.3.0-next.2

cors.d.ts

2

AutoRouter.d.ts

@@ -7,3 +7,3 @@ import { RouteHandler } from 'IttyRouter';

} & RouterOptions;
export declare const AutoRouter: ({ format, missing, finally: f, before, ...options }?: AutoRouterOptions) => import("./Router").RouterType<import("IttyRouter").Route, any[]>;
export declare const AutoRouter: ({ format, missing, finally: f, before, ...options }?: AutoRouterOptions) => import("./Router").RouterType<import("IttyRouter").IRequest, any[]>;
export {};

@@ -1,2 +0,2 @@

"use strict";const e=((e="text/plain; charset=utf-8",r)=>(t,{...o}={})=>{if(void 0===t||t instanceof Response)return t;const a=new Response(r?.(t)??t,o);return a.headers.set("content-type",e),a})("application/json; charset=utf-8",JSON.stringify),r=e=>({400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error"}[e]||"Unknown Error"),t=(t=500,o)=>{if(t instanceof Error){const{message:e,...a}=t;t=t.status||500,o={error:e||r(t),...a}}return o={status:t,..."object"==typeof o?o:{error:o||r(t)}},e(o,{status:t})},o=e=>{e.proxy=new Proxy(e.proxy||e,{get:(r,t)=>void 0!==r[t]?r[t].bind?.(e)||r[t]:r?.params?.[t]})};exports.AutoRouter=({format:r=e,missing:a=(()=>t(404)),finally:n=[],before:s=[],...c}={})=>(({base:e="",routes:r=[],...t}={})=>({__proto__:new Proxy({},{get:(t,o,a,n)=>"handle"==o?a.fetch:(t,...s)=>r.push([o.toUpperCase?.(),RegExp(`^${(n=(e+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),s,n])&&a}),routes:r,...t,async fetch(e,...o){let a,n,s=new URL(e.url),c=e.query={__proto__:null};for(let[e,r]of s.searchParams)c[e]=c[e]?[].concat(c[e],r):r;e:try{for(let r of t.before||[])if(null!=(a=await r(e.proxy??e,...o)))break e;r:for(let[t,c,f,i]of r)if((t==e.method||"ALL"==t)&&(n=s.pathname.match(c))){e.params=n.groups||{},e.route=i;for(let r of f)if(null!=(a=await r(e.proxy??e,...o)))break r}}catch(r){if(!t.catch)throw r;a=await t.catch(r,e.proxy??e,...o)}try{for(let r of t.finally||[])a=await r(a,e.proxy??e,...o)??a}catch(r){if(!t.catch)throw r;a=await t.catch(r,e.proxy??e,...o)}return a}}))({before:[o,...s],catch:t,finally:[(e,...r)=>e??a(e,...r),r,...n],...c});
"use strict";const r=((r="text/plain; charset=utf-8",e)=>(t,{...o}={})=>{if(void 0===t||t instanceof Response)return t;const a=new Response(e?.(t)??t,o);return a.headers.set("content-type",r),a})("application/json; charset=utf-8",JSON.stringify),e=r=>({400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error"}[r]||"Unknown Error"),t=(t=500,o)=>{if(t instanceof Error){const{message:r,...a}=t;t=t.status||500,o={error:r||e(t),...a}}return o={status:t,..."object"==typeof o?o:{error:o||e(t)}},r(o,{status:t})},o=r=>{r.proxy=new Proxy(r.proxy||r,{get:(e,t)=>void 0!==e[t]?e[t].bind?.(r)||e[t]:e?.params?.[t]})};exports.AutoRouter=({format:e=r,missing:a=(()=>t(404)),finally:n=[],before:s=[],...c}={})=>(({base:r="",routes:e=[],...t}={})=>({__proto__:new Proxy({},{get:(t,o,a,n)=>(t,...s)=>e.push([o.toUpperCase?.(),RegExp(`^${(n=(r+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),s,n])&&a}),routes:e,...t,async fetch(r,...o){let a,n,s=new URL(r.url),c=r.query={__proto__:null};for(let[r,e]of s.searchParams)c[r]=c[r]?[].concat(c[r],e):e;r:try{for(let e of t.before||[])if(null!=(a=await e(r.proxy??r,...o)))break r;e:for(let[t,c,f,i]of e)if((t==r.method||"ALL"==t)&&(n=s.pathname.match(c))){r.params=n.groups||{},r.route=i;for(let e of f)if(null!=(a=await e(r.proxy??r,...o)))break e}}catch(e){if(!t.catch)throw e;a=await t.catch(e,r.proxy??r,...o)}try{for(let e of t.finally||[])a=await e(a,r.proxy??r,...o)??a}catch(e){if(!t.catch)throw e;a=await t.catch(e,r.proxy??r,...o)}return a}}))({before:[o,...s],catch:t,finally:[(r,...e)=>r??a(r,...e),e,...n],...c});
//# sourceMappingURL=AutoRouter.js.map

@@ -17,2 +17,2 @@ export * from './IttyRouter';

export * from './withParams';
export * from './createCors';
export * from './cors';

@@ -1,2 +0,2 @@

"use strict";const e=({base:e="",routes:t=[],...o}={})=>({__proto__:new Proxy({},{get:(o,r,s,a)=>"handle"==r?s.fetch:(o,...n)=>t.push([r.toUpperCase?.(),RegExp(`^${(a=(e+o).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),n,a])&&s}),routes:t,...o,async fetch(e,...r){let s,a,n=new URL(e.url),c=e.query={__proto__:null};for(let[e,t]of n.searchParams)c[e]=c[e]?[].concat(c[e],t):t;e:try{for(let t of o.before||[])if(null!=(s=await t(e.proxy??e,...r)))break e;t:for(let[o,c,p,l]of t)if((o==e.method||"ALL"==o)&&(a=n.pathname.match(c))){e.params=a.groups||{},e.route=l;for(let t of p)if(null!=(s=await t(e.proxy??e,...r)))break t}}catch(t){if(!o.catch)throw t;s=await o.catch(t,e.proxy??e,...r)}try{for(let t of o.finally||[])s=await t(s,e.proxy??e,...r)??s}catch(t){if(!o.catch)throw t;s=await o.catch(t,e.proxy??e,...r)}return s}}),t=(e="text/plain; charset=utf-8",t)=>(o,{...r}={})=>{if(void 0===o||o instanceof Response)return o;const s=new Response(t?.(o)??o,r);return s.headers.set("content-type",e),s},o=t("application/json; charset=utf-8",JSON.stringify),r=e=>({400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error"}[e]||"Unknown Error"),s=(e=500,t)=>{if(e instanceof Error){const{message:o,...s}=e;e=e.status||500,t={error:o||r(e),...s}}return t={status:e,..."object"==typeof t?t:{error:t||r(e)}},o(t,{status:e})},a=e=>{e.proxy=new Proxy(e.proxy||e,{get:(t,o)=>void 0!==t[o]?t[o].bind?.(e)||t[o]:t?.params?.[o]})};class n extends Error{status;constructor(e=500,t){super("object"==typeof t?t.error:t),"object"==typeof t&&Object.assign(this,t),this.status=e}}const c=t("text/plain; charset=utf-8",String),p=t("text/html"),l=t("image/jpeg"),i=t("image/png"),u=t("image/webp");exports.AutoRouter=({format:t=o,missing:r=(()=>s(404)),finally:n=[],before:c=[],...p}={})=>e({before:[a,...c],catch:s,finally:[(e,...t)=>e??r(e,...t),t,...n],...p}),exports.IttyRouter=({base:e="",routes:t=[],...o}={})=>({__proto__:new Proxy({},{get:(o,r,s,a)=>(o,...n)=>t.push([r.toUpperCase?.(),RegExp(`^${(a=(e+o).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),n,a])&&s}),routes:t,...o,async fetch(e,...o){let r,s,a=new URL(e.url),n=e.query={__proto__:null};for(let[e,t]of a.searchParams)n[e]=n[e]?[].concat(n[e],t):t;for(let[n,c,p,l]of t)if((n==e.method||"ALL"==n)&&(s=a.pathname.match(c))){e.params=s.groups||{},e.route=l;for(let t of p)if(null!=(r=await t(e.proxy??e,...o)))return r}}}),exports.Router=e,exports.StatusError=n,exports.createCors=(e={})=>{const{origins:t=["*"],maxAge:o,methods:r=["GET"],headers:s={}}=e;let a;const n="function"==typeof t?t:e=>t.includes(e)||t.includes("*"),c={"content-type":"application/json","Access-Control-Allow-Methods":r.join(", "),...s};o&&(c["Access-Control-Max-Age"]=o);return{corsify:e=>{if(!e)throw new Error("No fetch handler responded and no upstream to proxy to specified.");const{headers:t,status:o,body:r}=e;return[101,301,302,308].includes(o)||t.get("access-control-allow-origin")?e:new Response(r,{status:o,headers:{...Object.fromEntries(t),...c,...a,"content-type":t.get("content-type")}})},preflight:e=>{const t=[...new Set(["OPTIONS",...r])],o=e.headers.get("origin")||"";if(a=n(o)&&{"Access-Control-Allow-Origin":o},"OPTIONS"===e.method){const o={...c,"Access-Control-Allow-Methods":t.join(", "),"Access-Control-Allow-Headers":e.headers.get("Access-Control-Request-Headers"),...a};return new Response(null,{headers:e.headers.get("Origin")&&e.headers.get("Access-Control-Request-Method")&&e.headers.get("Access-Control-Request-Headers")?o:{Allow:t.join(", ")}})}}}},exports.createResponse=t,exports.error=s,exports.html=p,exports.jpeg=l,exports.json=o,exports.png=i,exports.status=(e,t)=>new Response(null,{...t,status:e}),exports.text=c,exports.webp=u,exports.withContent=async e=>{e.content=await e.clone().json().catch((()=>e.clone().formData())).catch((()=>e.text()))},exports.withCookies=e=>{e.cookies=(e.headers.get("Cookie")||"").split(/;\s*/).map((e=>e.split(/=(.+)/))).reduce(((e,[t,o])=>o?(e[t]=o,e):e),{})},exports.withParams=a;
"use strict";const e=({base:e="",routes:t=[],...r}={})=>({__proto__:new Proxy({},{get:(r,o,s,a)=>(r,...n)=>t.push([o.toUpperCase?.(),RegExp(`^${(a=(e+r).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),n,a])&&s}),routes:t,...r,async fetch(e,...o){let s,a,n=new URL(e.url),c=e.query={__proto__:null};for(let[e,t]of n.searchParams)c[e]=c[e]?[].concat(c[e],t):t;e:try{for(let t of r.before||[])if(null!=(s=await t(e.proxy??e,...o)))break e;t:for(let[r,c,l,p]of t)if((r==e.method||"ALL"==r)&&(a=n.pathname.match(c))){e.params=a.groups||{},e.route=p;for(let t of l)if(null!=(s=await t(e.proxy??e,...o)))break t}}catch(t){if(!r.catch)throw t;s=await r.catch(t,e.proxy??e,...o)}try{for(let t of r.finally||[])s=await t(s,e.proxy??e,...o)??s}catch(t){if(!r.catch)throw t;s=await r.catch(t,e.proxy??e,...o)}return s}}),t=(e="text/plain; charset=utf-8",t)=>(r,{...o}={})=>{if(void 0===r||r instanceof Response)return r;const s=new Response(t?.(r)??r,o);return s.headers.set("content-type",e),s},r=t("application/json; charset=utf-8",JSON.stringify),o=e=>({400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error"}[e]||"Unknown Error"),s=(e=500,t)=>{if(e instanceof Error){const{message:r,...s}=e;e=e.status||500,t={error:r||o(e),...s}}return t={status:e,..."object"==typeof t?t:{error:t||o(e)}},r(t,{status:e})},a=e=>{e.proxy=new Proxy(e.proxy||e,{get:(t,r)=>void 0!==t[r]?t[r].bind?.(e)||t[r]:t?.params?.[r]})};class n extends Error{status;constructor(e=500,t){super("object"==typeof t?t.error:t),"object"==typeof t&&Object.assign(this,t),this.status=e}}const c=t("text/plain; charset=utf-8",String),l=t("text/html"),p=t("image/jpeg"),i=t("image/png"),u=t("image/webp");exports.AutoRouter=({format:t=r,missing:o=(()=>s(404)),finally:n=[],before:c=[],...l}={})=>e({before:[a,...c],catch:s,finally:[(e,...t)=>e??o(e,...t),t,...n],...l}),exports.IttyRouter=({base:e="",routes:t=[],...r}={})=>({__proto__:new Proxy({},{get:(r,o,s,a)=>(r,...n)=>t.push([o.toUpperCase(),RegExp(`^${(a=(e+r).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),n,a])&&s}),routes:t,...r,async fetch(e,...r){let o,s,a=new URL(e.url),n=e.query={__proto__:null};for(let[e,t]of a.searchParams)n[e]=n[e]?[].concat(n[e],t):t;for(let[n,c,l,p]of t)if((n==e.method||"ALL"==n)&&(s=a.pathname.match(c))){e.params=s.groups||{},e.route=p;for(let t of l)if(null!=(o=await t(e.proxy??e,...r)))return o}}}),exports.Router=e,exports.StatusError=n,exports.cors=(e={})=>{const{origin:t="*",credentials:r=!1,allowMethods:o=["*"],allowHeaders:s,exposeHeaders:a,maxAge:n}=e,c={"access-control-allow-headers":s?.join?.(",")??s,"access-control-expose-headers":a?.join?.(",")??a,"access-control-allow-methods":o?.join?.(",")??o,"access-control-max-age":n,"access-control-allow-credentials":r},l=e=>{const o=e?.headers.get("origin");return!0===t?o:t instanceof RegExp?t.test(o)?o:void 0:Array.isArray(t)?t.includes(o)?o:void 0:t instanceof Function?t(o):"*"==t&&r?o:t};return{corsify:(e,t)=>e?.headers?.get("access-control-allow-origin")?e:new Response(e.body,{...e,headers:[...e.headers,["access-control-allow-origin",l(t)],...Object.entries(c)].filter((e=>e[1]))}),preflight:e=>{if("OPTIONS"==e.method)return new Response(null,{status:204,headers:Object.entries({"access-control-allow-origin":l(e),...c}).filter((e=>e[1]))})}}},exports.createResponse=t,exports.error=s,exports.html=l,exports.jpeg=p,exports.json=r,exports.png=i,exports.status=(e,t)=>new Response(null,{...t,status:e}),exports.text=c,exports.webp=u,exports.withContent=async e=>{e.content=e.body?await e.clone().json().catch((()=>e.clone().formData())).catch((()=>e.text())):void 0},exports.withCookies=e=>{e.cookies=(e.headers.get("Cookie")||"").split(/;\s*/).map((e=>e.split(/=(.+)/))).reduce(((e,[t,r])=>r?(e[t]=r,e):e),{})},exports.withParams=a;
//# sourceMappingURL=index.js.map

@@ -1,4 +0,2 @@

export type GenericTraps = {
[key: string]: any;
};
export type GenericTraps = Record<string, any>;
export type RequestLike = {

@@ -25,4 +23,4 @@ method: string;

} & Record<string, any>;
export type RouteHandler<I = IRequest, A extends any[] = any[]> = {
(request: I, ...args: A): any;
export type RouteHandler<R = IRequest, Args extends Array<any> = any[]> = {
(request: R, ...args: Args): any;
};

@@ -35,3 +33,3 @@ export type RouteEntry = [

];
export type Route = <RequestType = IRequest, Args extends any[] = any[], RT = IttyRouterType>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RT;
export type Route<R = IRequest, A extends Array<any> = any[]> = <RequestType = R, Args extends Array<any> = A>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => IttyRouterType<RequestType, Args>;
export type UniversalRoute<RequestType = IRequest, Args extends any[] = any[]> = (path: string, ...handlers: RouteHandler<RequestType, Args>[]) => IttyRouterType<UniversalRoute<RequestType, Args>, Args>;

@@ -42,15 +40,15 @@ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;

};
export type IttyRouterType<R = Route, Args extends any[] = any[]> = {
export type IttyRouterType<R = IRequest, A extends any[] = any[], Output = any> = {
__proto__: IttyRouterType<R>;
routes: RouteEntry[];
fetch: <A extends any[] = Args>(request: RequestLike, ...extra: Equal<R, Args> extends true ? A : Args) => Promise<any>;
all: R;
delete: R;
get: R;
head: R;
options: R;
patch: R;
post: R;
put: R;
} & CustomRoutes<R> & Record<string, any>;
export declare const IttyRouter: <RequestType = IRequest, Args extends any[] = any[], RouteType = Equal<RequestType, IRequest> extends true ? Route : UniversalRoute<RequestType, Args>>({ base, routes, ...other }?: IttyRouterOptions) => IttyRouterType<RouteType, Args>;
fetch: <Args extends any[] = A>(request: RequestLike, ...extra: Args) => Promise<Output>;
all: Route<R, A>;
delete: Route<R, A>;
get: Route<R, A>;
head: Route<R, A>;
options: Route<R, A>;
patch: Route<R, A>;
post: Route<R, A>;
put: Route<R, A>;
} & CustomRoutes<Route<R, A>>;
export declare const IttyRouter: <RequestType = IRequest, Args extends any[] = any[]>({ base, routes, ...other }?: IttyRouterOptions) => IttyRouterType<RequestType, Args>;

@@ -1,2 +0,2 @@

"use strict";exports.IttyRouter=({base:e="",routes:r=[],...t}={})=>({__proto__:new Proxy({},{get:(t,o,a,p)=>(t,...l)=>r.push([o.toUpperCase?.(),RegExp(`^${(p=(e+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),l,p])&&a}),routes:r,...t,async fetch(e,...t){let o,a,p=new URL(e.url),l=e.query={__proto__:null};for(let[e,r]of p.searchParams)l[e]=l[e]?[].concat(l[e],r):r;for(let[l,s,c,u]of r)if((l==e.method||"ALL"==l)&&(a=p.pathname.match(s))){e.params=a.groups||{},e.route=u;for(let r of c)if(null!=(o=await r(e.proxy??e,...t)))return o}}});
"use strict";exports.IttyRouter=({base:e="",routes:r=[],...t}={})=>({__proto__:new Proxy({},{get:(t,o,a,p)=>(t,...l)=>r.push([o.toUpperCase(),RegExp(`^${(p=(e+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),l,p])&&a}),routes:r,...t,async fetch(e,...t){let o,a,p=new URL(e.url),l=e.query={__proto__:null};for(let[e,r]of p.searchParams)l[e]=l[e]?[].concat(l[e],r):r;for(let[l,s,c,u]of r)if((l==e.method||"ALL"==l)&&(a=p.pathname.match(s))){e.params=a.groups||{},e.route=u;for(let r of c)if(null!=(o=await r(e.proxy??e,...t)))return o}}});
//# sourceMappingURL=IttyRouter.js.map
{
"name": "itty-router",
"version": "4.3.0-next.1",
"version": "4.3.0-next.2",
"description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.",

@@ -19,6 +19,6 @@ "main": "./index.js",

},
"./createCors": {
"import": "./createCors.mjs",
"require": "./createCors.js",
"types": "./createCors.d.ts"
"./cors": {
"import": "./cors.mjs",
"require": "./cors.js",
"types": "./cors.d.ts"
},

@@ -25,0 +25,0 @@ "./createResponse": {

@@ -63,3 +63,5 @@ <p align="center">

export default AutoRouter()
const router = AutoRouter()
router
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)

@@ -69,2 +71,4 @@ .get('/json', () => [1,2,3])

export default router
// that's it ^-^

@@ -87,2 +91,5 @@ ```

#### Constant Feedback, Suggestions, Moral Support & Community Building
- TBD
#### Core Concepts

@@ -89,0 +96,0 @@

@@ -1,2 +0,2 @@

import { Equal, IRequest, IttyRouterOptions, IttyRouterType, Route, RouteHandler, UniversalRoute } from './IttyRouter';
import { IRequest, IttyRouterOptions, IttyRouterType, Route, RouteHandler } from './IttyRouter';
export type ResponseHandler<ResponseType = any, RequestType = IRequest, Args extends any[] = any[]> = (response: ResponseType, request: RequestType, ...args: Args) => any;

@@ -14,2 +14,2 @@ export type ErrorHandler<ErrorType = Error, RequestType = IRequest, Args extends any[] = any[]> = (response: ErrorType, request: RequestType, ...args: Args) => any;

} & IttyRouterOptions;
export declare const Router: <RequestType = IRequest, Args extends any[] = any[], RouteType = Equal<RequestType, IRequest> extends true ? Route : UniversalRoute<RequestType, Args>>({ base, routes, ...other }?: RouterOptions) => RouterType<RouteType, Args>;
export declare const Router: <RequestType = IRequest, Args extends any[] = any[]>({ base, routes, ...other }?: RouterOptions) => RouterType<RequestType, Args>;

@@ -1,2 +0,2 @@

"use strict";exports.Router=({base:e="",routes:r=[],...t}={})=>({__proto__:new Proxy({},{get:(t,a,o,c)=>"handle"==a?o.fetch:(t,...l)=>r.push([a.toUpperCase?.(),RegExp(`^${(c=(e+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),l,c])&&o}),routes:r,...t,async fetch(e,...a){let o,c,l=new URL(e.url),p=e.query={__proto__:null};for(let[e,r]of l.searchParams)p[e]=p[e]?[].concat(p[e],r):r;e:try{for(let r of t.before||[])if(null!=(o=await r(e.proxy??e,...a)))break e;r:for(let[t,p,f,h]of r)if((t==e.method||"ALL"==t)&&(c=l.pathname.match(p))){e.params=c.groups||{},e.route=h;for(let r of f)if(null!=(o=await r(e.proxy??e,...a)))break r}}catch(r){if(!t.catch)throw r;o=await t.catch(r,e.proxy??e,...a)}try{for(let r of t.finally||[])o=await r(o,e.proxy??e,...a)??o}catch(r){if(!t.catch)throw r;o=await t.catch(r,e.proxy??e,...a)}return o}});
"use strict";exports.Router=({base:r="",routes:e=[],...t}={})=>({__proto__:new Proxy({},{get:(t,a,o,c)=>(t,...l)=>e.push([a.toUpperCase?.(),RegExp(`^${(c=(r+t).replace(/\/+(\/|$)/g,"$1")).replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),l,c])&&o}),routes:e,...t,async fetch(r,...a){let o,c,l=new URL(r.url),p=r.query={__proto__:null};for(let[r,e]of l.searchParams)p[r]=p[r]?[].concat(p[r],e):e;r:try{for(let e of t.before||[])if(null!=(o=await e(r.proxy??r,...a)))break r;e:for(let[t,p,f,h]of e)if((t==r.method||"ALL"==t)&&(c=l.pathname.match(p))){r.params=c.groups||{},r.route=h;for(let e of f)if(null!=(o=await e(r.proxy??r,...a)))break e}}catch(e){if(!t.catch)throw e;o=await t.catch(e,r.proxy??r,...a)}try{for(let e of t.finally||[])o=await e(o,r.proxy??r,...a)??o}catch(e){if(!t.catch)throw e;o=await t.catch(e,r.proxy??r,...a)}return o}});
//# sourceMappingURL=Router.js.map

@@ -1,2 +0,2 @@

"use strict";exports.withContent=async t=>{t.content=await t.clone().json().catch((()=>t.clone().formData())).catch((()=>t.text()))};
"use strict";exports.withContent=async t=>{t.content=t.body?await t.clone().json().catch((()=>t.clone().formData())).catch((()=>t.text())):void 0};
//# sourceMappingURL=withContent.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc