itty-router 3.0.11-next.13 → 3.0.11-next.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.
@@ -1 +1,13 @@
1
- "use strict";class r extends Error{status;constructor(r=500,t="Internal Error."){super(t),this.name="StatusError",this.status=r}}exports.StatusError=r;
1
+ 'use strict';
2
+
3
+ class StatusError extends Error {
4
+ status;
5
+ constructor(status = 500, message = 'Internal Error.') {
6
+ super(message);
7
+ this.name = 'StatusError';
8
+ this.status = status;
9
+ }
10
+ }
11
+
12
+ exports.StatusError = StatusError;
13
+ //# sourceMappingURL=StatusError.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusError.cjs","sources":["../../src/extras/StatusError.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAM,MAAO,WAAY,SAAQ,KAAK,CAAA;AACpC,IAAA,MAAM,CAAQ;AAEd,IAAA,WAAA,CAAY,MAAiB,GAAA,GAAG,EAAE,OAAA,GAAkB,iBAAiB,EAAA;QACnE,KAAK,CAAC,OAAO,CAAC,CAAA;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;AACzB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;KACrB;AACF;;;;"}
@@ -1 +1,11 @@
1
- class r extends Error{status;constructor(r=500,t="Internal Error."){super(t),this.name="StatusError",this.status=r}}export{r as StatusError};
1
+ class StatusError extends Error {
2
+ status;
3
+ constructor(status = 500, message = 'Internal Error.') {
4
+ super(message);
5
+ this.name = 'StatusError';
6
+ this.status = status;
7
+ }
8
+ }
9
+
10
+ export { StatusError };
11
+ //# sourceMappingURL=StatusError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusError.mjs","sources":["../../src/extras/StatusError.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAM,MAAO,WAAY,SAAQ,KAAK,CAAA;AACpC,IAAA,MAAM,CAAQ;AAEd,IAAA,WAAA,CAAY,MAAiB,GAAA,GAAG,EAAE,OAAA,GAAkB,iBAAiB,EAAA;QACnE,KAAK,CAAC,OAAO,CAAC,CAAA;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;AACzB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;KACrB;AACF;;;;"}
@@ -1 +1,18 @@
1
- "use strict";exports.createResponse=(e="text/plain; charset=utf-8")=>(t,s={})=>{const{headers:n={},...r}=s;return"object"==typeof t?new Response(JSON.stringify(t),{headers:{"Content-Type":e,...n},...r}):new Response(t,s)};
1
+ 'use strict';
2
+
3
+ const createResponse = (format = 'text/plain; charset=utf-8') => (body, options = {}) => {
4
+ const { headers = {}, ...rest } = options;
5
+ if (typeof body === 'object') {
6
+ return new Response(JSON.stringify(body), {
7
+ headers: {
8
+ 'Content-Type': format,
9
+ ...headers,
10
+ },
11
+ ...rest,
12
+ });
13
+ }
14
+ return new Response(body, options);
15
+ };
16
+
17
+ exports.createResponse = createResponse;
18
+ //# sourceMappingURL=createResponse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createResponse.cjs","sources":["../../src/extras/createResponse.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQa,MAAA,cAAc,GAAG,CAAC,SAAiB,2BAA2B,KACzE,CAAC,IAAI,EAAE,OAAoC,GAAA,EAAE,KAAI;IAC/C,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;AAEzC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;AACxC,YAAA,OAAO,EAAE;AACP,gBAAA,cAAc,EAAE,MAAM;AACtB,gBAAA,GAAG,OAAO;AACX,aAAA;AACD,YAAA,GAAG,IAAI;AACR,SAAA,CAAC,CAAA;AACH,KAAA;AAED,IAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACpC;;;;"}
@@ -1 +1,16 @@
1
- const e=(e="text/plain; charset=utf-8")=>(t,n={})=>{const{headers:s={},...o}=n;return"object"==typeof t?new Response(JSON.stringify(t),{headers:{"Content-Type":e,...s},...o}):new Response(t,n)};export{e as createResponse};
1
+ const createResponse = (format = 'text/plain; charset=utf-8') => (body, options = {}) => {
2
+ const { headers = {}, ...rest } = options;
3
+ if (typeof body === 'object') {
4
+ return new Response(JSON.stringify(body), {
5
+ headers: {
6
+ 'Content-Type': format,
7
+ ...headers,
8
+ },
9
+ ...rest,
10
+ });
11
+ }
12
+ return new Response(body, options);
13
+ };
14
+
15
+ export { createResponse };
16
+ //# sourceMappingURL=createResponse.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createResponse.mjs","sources":["../../src/extras/createResponse.ts"],"sourcesContent":[null],"names":[],"mappings":"AAQa,MAAA,cAAc,GAAG,CAAC,SAAiB,2BAA2B,KACzE,CAAC,IAAI,EAAE,OAAoC,GAAA,EAAE,KAAI;IAC/C,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;AAEzC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;AACxC,YAAA,OAAO,EAAE;AACP,gBAAA,cAAc,EAAE,MAAM;AACtB,gBAAA,GAAG,OAAO;AACX,aAAA;AACD,YAAA,GAAG,IAAI;AACR,SAAA,CAAC,CAAA;AACH,KAAA;AAED,IAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACpC;;;;"}
package/extras/index.cjs CHANGED
@@ -1 +1,48 @@
1
- "use strict";exports.withContent=async t=>{let e=t.headers.get("content-type");t.content=void 0;try{e&&(e.includes("application/json")&&(t.content=await t.json()),["application/x-www-form-urlencoded","multipart/form-data"].includes(e)&&(t.content=await t.formData()))}catch(t){}},exports.withCookies=t=>{t.cookies={};try{t.cookies=(t.headers.get("Cookie")||"").split(/;\s*/).map((t=>t.split(/=(.+)/))).reduce(((t,[e,o])=>(t[e]=o,t)),{})}catch(t){}},exports.withParams=t=>{t.proxy=new Proxy(t.proxy||t,{get:(t,e)=>void 0!==t[e]?t[e]:t?.params?.[e]})};
1
+ 'use strict';
2
+
3
+ // withContent - embeds any request body as request.content
4
+ const withContent = async (request) => {
5
+ let contentType = request.headers.get('content-type');
6
+ request.content = undefined;
7
+ try {
8
+ if (contentType) {
9
+ if (contentType.includes('application/json')) {
10
+ request.content = await request.json();
11
+ }
12
+ if (['application/x-www-form-urlencoded', 'multipart/form-data'].includes(contentType)) {
13
+ request.content = await request.formData();
14
+ }
15
+ }
16
+ }
17
+ catch (err) { } // silently fail on error
18
+ };
19
+
20
+ // withCookies - embeds cookies object into the request
21
+ const withCookies = (request) => {
22
+ request.cookies = {};
23
+ try {
24
+ request.cookies = (request.headers.get('Cookie') || '')
25
+ .split(/;\s*/)
26
+ .map((pair) => pair.split(/=(.+)/))
27
+ .reduce((acc, [key, value]) => {
28
+ acc[key] = value;
29
+ return acc;
30
+ }, {});
31
+ }
32
+ catch (err) { }
33
+ };
34
+
35
+ const withParams = (request) => {
36
+ request.proxy = new Proxy(request.proxy || request, {
37
+ get: (obj, prop) => {
38
+ if (obj[prop] !== undefined)
39
+ return obj[prop];
40
+ return obj?.params?.[prop];
41
+ }
42
+ });
43
+ };
44
+
45
+ exports.withContent = withContent;
46
+ exports.withCookies = withCookies;
47
+ exports.withParams = withParams;
48
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/extras/withContent.ts","../../src/extras/withCookies.ts","../../src/extras/withParams.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;AAEA;MACa,WAAW,GAAG,OAAO,OAAiB,KAAmB;IACpE,IAAI,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,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I;AACjB,YAAA,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,gBAAA,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;AAE7C,YAAA,OAAO,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;SAC3B;AACF,KAAA,CAAC,CAAA;AACJ;;;;;;"}
package/extras/index.mjs CHANGED
@@ -1 +1,44 @@
1
- const t=async t=>{let o=t.headers.get("content-type");t.content=void 0;try{o&&(o.includes("application/json")&&(t.content=await t.json()),["application/x-www-form-urlencoded","multipart/form-data"].includes(o)&&(t.content=await t.formData()))}catch(t){}},o=t=>{t.cookies={};try{t.cookies=(t.headers.get("Cookie")||"").split(/;\s*/).map((t=>t.split(/=(.+)/))).reduce(((t,[o,e])=>(t[o]=e,t)),{})}catch(t){}},e=t=>{t.proxy=new Proxy(t.proxy||t,{get:(t,o)=>void 0!==t[o]?t[o]:t?.params?.[o]})};export{t as withContent,o as withCookies,e as withParams};
1
+ // withContent - embeds any request body as request.content
2
+ const withContent = async (request) => {
3
+ let contentType = request.headers.get('content-type');
4
+ request.content = undefined;
5
+ try {
6
+ if (contentType) {
7
+ if (contentType.includes('application/json')) {
8
+ request.content = await request.json();
9
+ }
10
+ if (['application/x-www-form-urlencoded', 'multipart/form-data'].includes(contentType)) {
11
+ request.content = await request.formData();
12
+ }
13
+ }
14
+ }
15
+ catch (err) { } // silently fail on error
16
+ };
17
+
18
+ // withCookies - embeds cookies object into the request
19
+ const withCookies = (request) => {
20
+ request.cookies = {};
21
+ try {
22
+ request.cookies = (request.headers.get('Cookie') || '')
23
+ .split(/;\s*/)
24
+ .map((pair) => pair.split(/=(.+)/))
25
+ .reduce((acc, [key, value]) => {
26
+ acc[key] = value;
27
+ return acc;
28
+ }, {});
29
+ }
30
+ catch (err) { }
31
+ };
32
+
33
+ const withParams = (request) => {
34
+ request.proxy = new Proxy(request.proxy || request, {
35
+ get: (obj, prop) => {
36
+ if (obj[prop] !== undefined)
37
+ return obj[prop];
38
+ return obj?.params?.[prop];
39
+ }
40
+ });
41
+ };
42
+
43
+ export { withContent, withCookies, withParams };
44
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../src/extras/withContent.ts","../../src/extras/withCookies.ts","../../src/extras/withParams.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":"AAEA;MACa,WAAW,GAAG,OAAO,OAAiB,KAAmB;IACpE,IAAI,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IAE3B,IAAI;AACF,QAAA,IAAI,WAAW,EAAE;AACf,YAAA,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;gBAC5C,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;AACvC,aAAA;YAED,IAAI,CAAC,mCAAmC,EAAE,qBAAqB,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACtF,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;AAC3C,aAAA;AACF,SAAA;AACF,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE,GAAE;AAClB;;AChBA;AACa,MAAA,WAAW,GAAG,CAAC,OAAiB,KAAU;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;IACpB,IAAI;AACF,QAAA,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;aACnD,KAAK,CAAC,MAAM,CAAC;AACb,aAAA,GAAG,CAAC,CAAC,IAAY,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC5B,YAAA,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEhB,YAAA,OAAO,GAAG,CAAA;SACX,EAAE,EAAE,CAAC,CAAA;AACT,KAAA;IAAC,OAAO,GAAG,EAAE,GAAE;AAClB;;ACba,MAAA,UAAU,GAAG,CAAC,OAAiB,KAAU;IACpD,OAAO,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAClD,QAAA,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,KAAI;AACjB,YAAA,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,gBAAA,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;AAE7C,YAAA,OAAO,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;SAC3B;AACF,KAAA,CAAC,CAAA;AACJ;;;;"}
package/extras/json.cjs CHANGED
@@ -1 +1,22 @@
1
- "use strict";const e="application/json; charset=utf-8",t=((e="text/plain; charset=utf-8")=>(t,s={})=>{const{headers:n={},...o}=s;return"object"==typeof t?new Response(JSON.stringify(t),{headers:{"Content-Type":e,...n},...o}):new Response(t,s)})(e);exports.json=t,exports.mimeType=e;
1
+ 'use strict';
2
+
3
+ const createResponse = (format = 'text/plain; charset=utf-8') => (body, options = {}) => {
4
+ const { headers = {}, ...rest } = options;
5
+ if (typeof body === 'object') {
6
+ return new Response(JSON.stringify(body), {
7
+ headers: {
8
+ 'Content-Type': format,
9
+ ...headers,
10
+ },
11
+ ...rest,
12
+ });
13
+ }
14
+ return new Response(body, options);
15
+ };
16
+
17
+ const mimeType = 'application/json; charset=utf-8';
18
+ const json = createResponse(mimeType);
19
+
20
+ exports.json = json;
21
+ exports.mimeType = mimeType;
22
+ //# sourceMappingURL=json.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.cjs","sources":["../../src/extras/createResponse.ts","../../src/extras/json.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAQO,MAAM,cAAc,GAAG,CAAC,SAAiB,2BAA2B,KACzE,CAAC,IAAI,EAAE,OAAoC,GAAA,EAAE,KAAI;IAC/C,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;AAEzC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;AACxC,YAAA,OAAO,EAAE;AACP,gBAAA,cAAc,EAAE,MAAM;AACtB,gBAAA,GAAG,OAAO;AACX,aAAA;AACD,YAAA,GAAG,IAAI;AACR,SAAA,CAAC,CAAA;AACH,KAAA;AAED,IAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;;ACrBI,MAAM,QAAQ,GAAG,kCAAiC;MAE5C,IAAI,GAAG,cAAc,CAAC,QAAQ;;;;;"}
package/extras/json.mjs CHANGED
@@ -1 +1,19 @@
1
- const e="application/json; charset=utf-8",t=((e="text/plain; charset=utf-8")=>(t,n={})=>{const{headers:s={},...o}=n;return"object"==typeof t?new Response(JSON.stringify(t),{headers:{"Content-Type":e,...s},...o}):new Response(t,n)})(e);export{t as json,e as mimeType};
1
+ const createResponse = (format = 'text/plain; charset=utf-8') => (body, options = {}) => {
2
+ const { headers = {}, ...rest } = options;
3
+ if (typeof body === 'object') {
4
+ return new Response(JSON.stringify(body), {
5
+ headers: {
6
+ 'Content-Type': format,
7
+ ...headers,
8
+ },
9
+ ...rest,
10
+ });
11
+ }
12
+ return new Response(body, options);
13
+ };
14
+
15
+ const mimeType = 'application/json; charset=utf-8';
16
+ const json = createResponse(mimeType);
17
+
18
+ export { json, mimeType };
19
+ //# sourceMappingURL=json.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.mjs","sources":["../../src/extras/createResponse.ts","../../src/extras/json.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAQO,MAAM,cAAc,GAAG,CAAC,SAAiB,2BAA2B,KACzE,CAAC,IAAI,EAAE,OAAoC,GAAA,EAAE,KAAI;IAC/C,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;AAEzC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;AACxC,YAAA,OAAO,EAAE;AACP,gBAAA,cAAc,EAAE,MAAM;AACtB,gBAAA,GAAG,OAAO;AACX,aAAA;AACD,YAAA,GAAG,IAAI;AACR,SAAA,CAAC,CAAA;AACH,KAAA;AAED,IAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;;ACrBI,MAAM,QAAQ,GAAG,kCAAiC;MAE5C,IAAI,GAAG,cAAc,CAAC,QAAQ;;;;"}
@@ -1 +1,21 @@
1
- "use strict";exports.withContent=async t=>{let n=t.headers.get("content-type");t.content=void 0;try{n&&(n.includes("application/json")&&(t.content=await t.json()),["application/x-www-form-urlencoded","multipart/form-data"].includes(n)&&(t.content=await t.formData()))}catch(t){}};
1
+ 'use strict';
2
+
3
+ // withContent - embeds any request body as request.content
4
+ const withContent = async (request) => {
5
+ let contentType = request.headers.get('content-type');
6
+ request.content = undefined;
7
+ try {
8
+ if (contentType) {
9
+ if (contentType.includes('application/json')) {
10
+ request.content = await request.json();
11
+ }
12
+ if (['application/x-www-form-urlencoded', 'multipart/form-data'].includes(contentType)) {
13
+ request.content = await request.formData();
14
+ }
15
+ }
16
+ }
17
+ catch (err) { } // silently fail on error
18
+ };
19
+
20
+ exports.withContent = withContent;
21
+ //# sourceMappingURL=withContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withContent.cjs","sources":["../../src/extras/withContent.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;MACa,WAAW,GAAG,OAAO,OAAiB,KAAmB;IACpE,IAAI,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IAE3B,IAAI;AACF,QAAA,IAAI,WAAW,EAAE;AACf,YAAA,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;gBAC5C,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;AACvC,aAAA;YAED,IAAI,CAAC,mCAAmC,EAAE,qBAAqB,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACtF,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;AAC3C,aAAA;AACF,SAAA;AACF,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE,GAAE;AAClB;;;;"}
@@ -1 +1,19 @@
1
- const t=async t=>{let n=t.headers.get("content-type");t.content=void 0;try{n&&(n.includes("application/json")&&(t.content=await t.json()),["application/x-www-form-urlencoded","multipart/form-data"].includes(n)&&(t.content=await t.formData()))}catch(t){}};export{t as withContent};
1
+ // withContent - embeds any request body as request.content
2
+ const withContent = async (request) => {
3
+ let contentType = request.headers.get('content-type');
4
+ request.content = undefined;
5
+ try {
6
+ if (contentType) {
7
+ if (contentType.includes('application/json')) {
8
+ request.content = await request.json();
9
+ }
10
+ if (['application/x-www-form-urlencoded', 'multipart/form-data'].includes(contentType)) {
11
+ request.content = await request.formData();
12
+ }
13
+ }
14
+ }
15
+ catch (err) { } // silently fail on error
16
+ };
17
+
18
+ export { withContent };
19
+ //# sourceMappingURL=withContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withContent.mjs","sources":["../../src/extras/withContent.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;MACa,WAAW,GAAG,OAAO,OAAiB,KAAmB;IACpE,IAAI,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;IAE3B,IAAI;AACF,QAAA,IAAI,WAAW,EAAE;AACf,YAAA,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;gBAC5C,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;AACvC,aAAA;YAED,IAAI,CAAC,mCAAmC,EAAE,qBAAqB,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACtF,OAAO,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;AAC3C,aAAA;AACF,SAAA;AACF,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE,GAAE;AAClB;;;;"}
@@ -1 +1,19 @@
1
- "use strict";exports.withCookies=e=>{e.cookies={};try{e.cookies=(e.headers.get("Cookie")||"").split(/;\s*/).map((e=>e.split(/=(.+)/))).reduce(((e,[s,o])=>(e[s]=o,e)),{})}catch(e){}};
1
+ 'use strict';
2
+
3
+ // withCookies - embeds cookies object into the request
4
+ const withCookies = (request) => {
5
+ request.cookies = {};
6
+ try {
7
+ request.cookies = (request.headers.get('Cookie') || '')
8
+ .split(/;\s*/)
9
+ .map((pair) => pair.split(/=(.+)/))
10
+ .reduce((acc, [key, value]) => {
11
+ acc[key] = value;
12
+ return acc;
13
+ }, {});
14
+ }
15
+ catch (err) { }
16
+ };
17
+
18
+ exports.withCookies = withCookies;
19
+ //# sourceMappingURL=withCookies.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCookies.cjs","sources":["../../src/extras/withCookies.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;AACa,MAAA,WAAW,GAAG,CAAC,OAAiB,KAAU;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;IACpB,IAAI;AACF,QAAA,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;aACnD,KAAK,CAAC,MAAM,CAAC;AACb,aAAA,GAAG,CAAC,CAAC,IAAY,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC5B,YAAA,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEhB,YAAA,OAAO,GAAG,CAAA;SACX,EAAE,EAAE,CAAC,CAAA;AACT,KAAA;IAAC,OAAO,GAAG,EAAE,GAAE;AAClB;;;;"}
@@ -1 +1,17 @@
1
- const e=e=>{e.cookies={};try{e.cookies=(e.headers.get("Cookie")||"").split(/;\s*/).map((e=>e.split(/=(.+)/))).reduce(((e,[o,s])=>(e[o]=s,e)),{})}catch(e){}};export{e as withCookies};
1
+ // withCookies - embeds cookies object into the request
2
+ const withCookies = (request) => {
3
+ request.cookies = {};
4
+ try {
5
+ request.cookies = (request.headers.get('Cookie') || '')
6
+ .split(/;\s*/)
7
+ .map((pair) => pair.split(/=(.+)/))
8
+ .reduce((acc, [key, value]) => {
9
+ acc[key] = value;
10
+ return acc;
11
+ }, {});
12
+ }
13
+ catch (err) { }
14
+ };
15
+
16
+ export { withCookies };
17
+ //# sourceMappingURL=withCookies.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCookies.mjs","sources":["../../src/extras/withCookies.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;AACa,MAAA,WAAW,GAAG,CAAC,OAAiB,KAAU;AACrD,IAAA,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;IACpB,IAAI;AACF,QAAA,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;aACnD,KAAK,CAAC,MAAM,CAAC;AACb,aAAA,GAAG,CAAC,CAAC,IAAY,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC5B,YAAA,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEhB,YAAA,OAAO,GAAG,CAAA;SACX,EAAE,EAAE,CAAC,CAAA;AACT,KAAA;IAAC,OAAO,GAAG,EAAE,GAAE;AAClB;;;;"}
@@ -1 +1,14 @@
1
- "use strict";exports.withParams=r=>{r.proxy=new Proxy(r.proxy||r,{get:(r,o)=>void 0!==r[o]?r[o]:r?.params?.[o]})};
1
+ 'use strict';
2
+
3
+ const withParams = (request) => {
4
+ request.proxy = new Proxy(request.proxy || request, {
5
+ get: (obj, prop) => {
6
+ if (obj[prop] !== undefined)
7
+ return obj[prop];
8
+ return obj?.params?.[prop];
9
+ }
10
+ });
11
+ };
12
+
13
+ exports.withParams = withParams;
14
+ //# sourceMappingURL=withParams.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withParams.cjs","sources":["../../src/extras/withParams.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEa,MAAA,UAAU,GAAG,CAAC,OAAiB,KAAU;IACpD,OAAO,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAClD,QAAA,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,KAAI;AACjB,YAAA,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,gBAAA,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;AAE7C,YAAA,OAAO,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;SAC3B;AACF,KAAA,CAAC,CAAA;AACJ;;;;"}
@@ -1 +1,12 @@
1
- const o=o=>{o.proxy=new Proxy(o.proxy||o,{get:(o,r)=>void 0!==o[r]?o[r]:o?.params?.[r]})};export{o as withParams};
1
+ const withParams = (request) => {
2
+ request.proxy = new Proxy(request.proxy || request, {
3
+ get: (obj, prop) => {
4
+ if (obj[prop] !== undefined)
5
+ return obj[prop];
6
+ return obj?.params?.[prop];
7
+ }
8
+ });
9
+ };
10
+
11
+ export { withParams };
12
+ //# sourceMappingURL=withParams.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withParams.mjs","sources":["../../src/extras/withParams.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEa,MAAA,UAAU,GAAG,CAAC,OAAiB,KAAU;IACpD,OAAO,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE;AAClD,QAAA,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,KAAI;AACjB,YAAA,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,gBAAA,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;AAE7C,YAAA,OAAO,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;SAC3B;AACF,KAAA,CAAC,CAAA;AACJ;;;;"}
package/index.cjs CHANGED
@@ -1 +1,88 @@
1
- "use strict";exports.Router=({base:e="",routes:r=[]}={})=>({__proto__:new Proxy({},{get:(a,o,t)=>(a,...p)=>r.push([o.toUpperCase(),RegExp(`^${(e+a).replace(/(\/?)\*/g,"($1.*)?").replace(/(\/$)|((?<=\/)\/)/,"").replace(/(:(\w+)\+)/,"(?<$2>.*)").replace(/:(\w+)(\?)?(\.)?/g,"$2(?<$1>[^/]+)$2$3").replace(/\.(?=[\w(])/,"\\.").replace(/\)\.\?\(([^\[]+)\[\^/g,"?)\\.?($1(?<=\\.)[^\\.")}/*$`),p])&&t}),routes:r,async handle(e,...a){let o,t,p=new URL(e.url),l=e.query={};for(let[e,r]of p.searchParams)l[e]=void 0===l[e]?r:[l[e],r].flat();for(let[l,s,c]of r)if((l===e.method||"ALL"===l)&&(t=p.pathname.match(s))){e.params=t.groups||{};for(let r of c)if(void 0!==(o=await r(e.proxy||e,...a)))return o}}});
1
+ 'use strict';
2
+
3
+ const Router = ({ base = '', routes = [] } = {}) =>
4
+ // @ts-expect-error TypeScript doesn't know that Proxy makes this work
5
+ ({
6
+ __proto__: new Proxy({}, {
7
+ get: (target, prop, receiver) => (route, ...handlers) => routes.push([
8
+ prop.toUpperCase(),
9
+ RegExp(`^${(base + route)
10
+ .replace(/(\/?)\*/g, '($1.*)?') // trailing wildcard
11
+ .replace(/(\/$)|((?<=\/)\/)/, '') // remove trailing slash or double slash from joins
12
+ .replace(/(:(\w+)\+)/, '(?<$2>.*)') // greedy params
13
+ .replace(/:(\w+)(\?)?(\.)?/g, '$2(?<$1>[^/]+)$2$3') // named params
14
+ .replace(/\.(?=[\w(])/, '\\.') // dot in path
15
+ .replace(/\)\.\?\(([^\[]+)\[\^/g, '?)\\.?($1(?<=\\.)[^\\.') // optional image format
16
+ }/*$`),
17
+ handlers,
18
+ ]) && receiver
19
+ }),
20
+ routes,
21
+ async handle(request, ...args) {
22
+ let response, match, url = new URL(request.url), query = request.query = {};
23
+ for (let [k, v] of url.searchParams) {
24
+ query[k] = query[k] === undefined ? v : [query[k], v].flat();
25
+ }
26
+ for (let [method, route, handlers] of routes) {
27
+ if ((method === request.method || method === 'ALL') && (match = url.pathname.match(route))) {
28
+ request.params = match.groups || {};
29
+ for (let handler of handlers) {
30
+ if ((response = await handler(request.proxy || request, ...args)) !== undefined)
31
+ return response;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ });
37
+ // type CustomMethods = {
38
+ // foo?: Route,
39
+ // bar?: Route,
40
+ // }
41
+ // // const router = Router() as RouterType & CustomMethods
42
+ // // router.foo()
43
+ // type RequestWithAuthors = {
44
+ // authors?: string[]
45
+ // } & IRequest
46
+ // // middleware: adds authors to the request
47
+ // const addAuthors = (request) => {
48
+ // request.authors = ['foo', 'bar']
49
+ // }
50
+ // const router = Router()
51
+ // type BooksResponse = {
52
+ // books: string[]
53
+ // }
54
+ // // FAILING EXAMPLE
55
+ // router.get('books', (request): BooksResponse => {
56
+ // request.foo = 'asd'
57
+ // return false // fails to return a Response with books
58
+ // })
59
+ // // PASSING EXAMPLE
60
+ // router.get('books', (request): BooksResponse => {
61
+ // request.foo = 'asd'
62
+ // return {
63
+ // books: ['foo', 'bar'] // passes!
64
+ // }
65
+ // })
66
+ // const router = Router()
67
+ // router.routes.push(['GET', /gsadfa/, []])
68
+ // type MyTraps = {
69
+ // foo?: Route;
70
+ // }
71
+ // const router = Router() as RouterType & MyTraps;
72
+ /*
73
+
74
+ {
75
+ name: string,
76
+ age: number,
77
+ handler: (name: string) => any,
78
+
79
+ ?? => Route
80
+ ?? => Route
81
+ ?? => Route
82
+ }
83
+
84
+
85
+ */
86
+
87
+ exports.Router = Router;
88
+ //# sourceMappingURL=index.cjs.map
package/index.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAqDa,MAAA,MAAM,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAoB,GAAA,EAAE;AACnE;AACA,CAAC;AACC,IAAA,SAAS,EAAE,IAAI,KAAK,CAAC,EAAgB,EAAE;QACrC,GAAG,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,QAAQ,KAAK,CAAC,KAAa,EAAE,GAAG,QAAwB,KAClF,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,CAAC,WAAW,EAAE;AAClB,YAAA,MAAM,CAAC,CAAI,CAAA,EAAA,CAAC,IAAI,GAAG,KAAK;AACrB,iBAAA,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC;AAC9B,iBAAA,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAChC,iBAAA,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC;AAClC,iBAAA,OAAO,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;AAClD,iBAAA,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC;AAC7B,iBAAA,OAAO,CAAC,uBAAuB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A;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AAGA;;;;;;;;;;;;;AAaE;;;;"}
package/index.mjs CHANGED
@@ -1 +1,86 @@
1
- const e=({base:e="",routes:r=[]}={})=>({__proto__:new Proxy({},{get:(a,o,t)=>(a,...p)=>r.push([o.toUpperCase(),RegExp(`^${(e+a).replace(/(\/?)\*/g,"($1.*)?").replace(/(\/$)|((?<=\/)\/)/,"").replace(/(:(\w+)\+)/,"(?<$2>.*)").replace(/:(\w+)(\?)?(\.)?/g,"$2(?<$1>[^/]+)$2$3").replace(/\.(?=[\w(])/,"\\.").replace(/\)\.\?\(([^\[]+)\[\^/g,"?)\\.?($1(?<=\\.)[^\\.")}/*$`),p])&&t}),routes:r,async handle(e,...a){let o,t,p=new URL(e.url),l=e.query={};for(let[e,r]of p.searchParams)l[e]=void 0===l[e]?r:[l[e],r].flat();for(let[l,s,c]of r)if((l===e.method||"ALL"===l)&&(t=p.pathname.match(s))){e.params=t.groups||{};for(let r of c)if(void 0!==(o=await r(e.proxy||e,...a)))return o}}});export{e as Router};
1
+ const Router = ({ base = '', routes = [] } = {}) =>
2
+ // @ts-expect-error TypeScript doesn't know that Proxy makes this work
3
+ ({
4
+ __proto__: new Proxy({}, {
5
+ get: (target, prop, receiver) => (route, ...handlers) => routes.push([
6
+ prop.toUpperCase(),
7
+ RegExp(`^${(base + route)
8
+ .replace(/(\/?)\*/g, '($1.*)?') // trailing wildcard
9
+ .replace(/(\/$)|((?<=\/)\/)/, '') // remove trailing slash or double slash from joins
10
+ .replace(/(:(\w+)\+)/, '(?<$2>.*)') // greedy params
11
+ .replace(/:(\w+)(\?)?(\.)?/g, '$2(?<$1>[^/]+)$2$3') // named params
12
+ .replace(/\.(?=[\w(])/, '\\.') // dot in path
13
+ .replace(/\)\.\?\(([^\[]+)\[\^/g, '?)\\.?($1(?<=\\.)[^\\.') // optional image format
14
+ }/*$`),
15
+ handlers,
16
+ ]) && receiver
17
+ }),
18
+ routes,
19
+ async handle(request, ...args) {
20
+ let response, match, url = new URL(request.url), query = request.query = {};
21
+ for (let [k, v] of url.searchParams) {
22
+ query[k] = query[k] === undefined ? v : [query[k], v].flat();
23
+ }
24
+ for (let [method, route, handlers] of routes) {
25
+ if ((method === request.method || method === 'ALL') && (match = url.pathname.match(route))) {
26
+ request.params = match.groups || {};
27
+ for (let handler of handlers) {
28
+ if ((response = await handler(request.proxy || request, ...args)) !== undefined)
29
+ return response;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ });
35
+ // type CustomMethods = {
36
+ // foo?: Route,
37
+ // bar?: Route,
38
+ // }
39
+ // // const router = Router() as RouterType & CustomMethods
40
+ // // router.foo()
41
+ // type RequestWithAuthors = {
42
+ // authors?: string[]
43
+ // } & IRequest
44
+ // // middleware: adds authors to the request
45
+ // const addAuthors = (request) => {
46
+ // request.authors = ['foo', 'bar']
47
+ // }
48
+ // const router = Router()
49
+ // type BooksResponse = {
50
+ // books: string[]
51
+ // }
52
+ // // FAILING EXAMPLE
53
+ // router.get('books', (request): BooksResponse => {
54
+ // request.foo = 'asd'
55
+ // return false // fails to return a Response with books
56
+ // })
57
+ // // PASSING EXAMPLE
58
+ // router.get('books', (request): BooksResponse => {
59
+ // request.foo = 'asd'
60
+ // return {
61
+ // books: ['foo', 'bar'] // passes!
62
+ // }
63
+ // })
64
+ // const router = Router()
65
+ // router.routes.push(['GET', /gsadfa/, []])
66
+ // type MyTraps = {
67
+ // foo?: Route;
68
+ // }
69
+ // const router = Router() as RouterType & MyTraps;
70
+ /*
71
+
72
+ {
73
+ name: string,
74
+ age: number,
75
+ handler: (name: string) => any,
76
+
77
+ ?? => Route
78
+ ?? => Route
79
+ ?? => Route
80
+ }
81
+
82
+
83
+ */
84
+
85
+ export { Router };
86
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["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AAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC7D,SAAA;QACD,KAAK,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,EAAE;YAC5C,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,IAAI,MAAM,KAAK,KAAK,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC1F,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAA;AACnC,gBAAA,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE;AAC5B,oBAAA,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,SAAS;AAAE,wBAAA,OAAO,QAAQ,CAAA;AACjG,iBAAA;AACF,aAAA;AACF,SAAA;KACF;AACF,CAAA,EAAC;AAEJ;AACA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AAGA;;;;;;;;;;;;;AAaE;;;;"}
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "itty-router",
3
- "version": "3.0.11-next.13",
3
+ "version": "3.0.11-next.14",
4
4
  "description": "Tiny, zero-dependency API router - built for Cloudflare Workers, but works everywhere!",
5
5
  "sourceType": "module",
6
- "main": "index.cjs",
6
+ "main": "index.js",
7
7
  "module": "index.mjs",
8
8
  "typings": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./esm/index.mjs",
12
+ "require": "./cjs/index.js"
13
+ },
14
+ "./extras": {
15
+ "import": "./extras/index.mjs",
16
+ "require": "./extras/index.js"
17
+ }
18
+ },
9
19
  "keywords": [
10
20
  "api",
11
21
  "router",