@sqrzro/server 4.0.0-alpha.48 → 4.0.0-alpha.49

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,10 +1,10 @@
1
- import { NextRequest, NextResponse } from 'next/server';
1
+ import { NextRequest } from 'next/server';
2
2
 
3
3
  interface ProxyRedirect {
4
- redirect: string;
4
+ redirect: string | number | null;
5
5
  }
6
6
  type ProxyFunction = (request: NextRequest) => Promise<ProxyRedirect | null>;
7
7
 
8
- declare function handleProxy(request: NextRequest, functions: ProxyFunction[]): Promise<NextResponse>;
8
+ declare function handleProxy(request: NextRequest, functions: ProxyFunction[]): Promise<Response>;
9
9
 
10
10
  export { type ProxyFunction, type ProxyRedirect, handleProxy };
@@ -1,2 +1,2 @@
1
- import {NextResponse}from'next/server';async function i(e,o){for(let n of o){let t=await n(e);if(t)return NextResponse.redirect(new URL(t.redirect,e.url))}return NextResponse.next()}var f=i;export{f as handleProxy};//# sourceMappingURL=index.js.map
1
+ import {NextResponse}from'next/server';async function i(t,n){for(let s of n){let r=await s(t);if(r?.redirect){let{redirect:e}=r;return typeof e=="number"?new Response(null,{status:e}):NextResponse.redirect(new URL(e,t.url))}}return NextResponse.next()}var u=i;export{u as handleProxy};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/proxy/handle-proxy.ts"],"names":["handleProxy","request","functions","func","result","NextResponse","handle_proxy_default"],"mappings":"uCAKA,eAAeA,CAAAA,CACXC,EACAC,CAAAA,CACqB,CACrB,IAAA,IAAWC,CAAAA,IAAQD,EAAW,CAC1B,IAAME,EAAS,MAAMD,CAAAA,CAAKF,CAAO,CAAA,CAEjC,GAAIG,CAAAA,CACA,OAAOC,aAAa,QAAA,CAAS,IAAI,GAAA,CAAID,CAAAA,CAAO,SAAUH,CAAAA,CAAQ,GAAG,CAAC,CAE1E,CAEA,OAAOI,YAAAA,CAAa,MACxB,KAEOC,CAAAA,CAAQN","file":"index.js","sourcesContent":["import { NextResponse } from 'next/server';\nimport type { NextRequest } from 'next/server';\n\nimport type { ProxyFunction } from './utility/interfaces';\n\nasync function handleProxy(\n request: NextRequest,\n functions: ProxyFunction[]\n): Promise<NextResponse> {\n for (const func of functions) {\n const result = await func(request);\n\n if (result) {\n return NextResponse.redirect(new URL(result.redirect, request.url));\n }\n }\n\n return NextResponse.next();\n}\n\nexport default handleProxy;\n"]}
1
+ {"version":3,"sources":["../../src/proxy/handle-proxy.ts"],"names":["handleProxy","request","functions","func","result","redirect","NextResponse","handle_proxy_default"],"mappings":"uCAKA,eAAeA,CAAAA,CAAYC,CAAAA,CAAsBC,CAAAA,CAA+C,CAC5F,IAAA,IAAWC,CAAAA,IAAQD,CAAAA,CAAW,CAC1B,IAAME,EAAS,MAAMD,CAAAA,CAAKF,CAAO,CAAA,CAEjC,GAAIG,CAAAA,EAAQ,QAAA,CAAU,CAClB,GAAM,CAAE,QAAA,CAAAC,CAAS,CAAA,CAAID,CAAAA,CAErB,OAAI,OAAOC,CAAAA,EAAa,QAAA,CACb,IAAI,QAAA,CAAS,IAAA,CAAM,CAAE,MAAA,CAAQA,CAAS,CAAC,CAAA,CAEvCC,YAAAA,CAAa,QAAA,CAAS,IAAI,GAAA,CAAID,CAAAA,CAAUJ,CAAAA,CAAQ,GAAG,CAAC,CAEnE,CACJ,CAEA,OAAOK,YAAAA,CAAa,IAAA,EACxB,CAEA,IAAOC,CAAAA,CAAQP","file":"index.js","sourcesContent":["import { NextResponse } from 'next/server';\nimport type { NextRequest } from 'next/server';\n\nimport type { ProxyFunction } from './utility/interfaces';\n\nasync function handleProxy(request: NextRequest, functions: ProxyFunction[]): Promise<Response> {\n for (const func of functions) {\n const result = await func(request);\n\n if (result?.redirect) {\n const { redirect } = result;\n\n if (typeof redirect === 'number') {\n return new Response(null, { status: redirect });\n } else {\n return NextResponse.redirect(new URL(redirect, request.url));\n }\n }\n }\n\n return NextResponse.next();\n}\n\nexport default handleProxy;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqrzro/server",
3
- "version": "4.0.0-alpha.48",
3
+ "version": "4.0.0-alpha.49",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",