@qwik.dev/router 2.0.0-beta.39 → 2.0.0-beta.40
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/lib/adapters/azure-swa/vite/index.mjs +45 -54
- package/lib/adapters/bun-server/vite/index.mjs +16 -22
- package/lib/adapters/cloud-run/vite/index.mjs +15 -19
- package/lib/adapters/cloudflare-pages/vite/index.mjs +46 -67
- package/lib/adapters/deno-server/vite/index.mjs +25 -39
- package/lib/adapters/netlify-edge/vite/index.mjs +50 -76
- package/lib/adapters/node-server/vite/index.mjs +16 -22
- package/lib/adapters/shared/vite/index.mjs +271 -360
- package/lib/adapters/ssg/vite/index.mjs +11 -15
- package/lib/adapters/vercel-edge/vite/index.mjs +74 -95
- package/lib/chunks/dev-preloaded-route-loader.mjs +2 -3
- package/lib/chunks/format.mjs +16 -23
- package/lib/chunks/fs.mjs +93 -106
- package/lib/chunks/head.qwik.mjs +1174 -1382
- package/lib/chunks/http-error.qwik.mjs +20 -28
- package/lib/chunks/pathname.mjs +50 -69
- package/lib/chunks/request-body-limit.mjs +25 -35
- package/lib/chunks/request-path.mjs +44 -55
- package/lib/chunks/routes.mjs +20 -41
- package/lib/chunks/server-error.mjs +15 -18
- package/lib/chunks/system.mjs +258 -326
- package/lib/chunks/url.mjs +56 -58
- package/lib/chunks/user-response.mjs +1616 -1804
- package/lib/chunks/worker-thread.mjs +254 -307
- package/lib/index.qwik.mjs +1637 -1918
- package/lib/middleware/aws-lambda/index.mjs +44 -52
- package/lib/middleware/azure-swa/index.mjs +85 -94
- package/lib/middleware/bun/index.mjs +118 -138
- package/lib/middleware/cloudflare-pages/index.mjs +83 -96
- package/lib/middleware/deno/index.mjs +104 -125
- package/lib/middleware/firebase/index.mjs +21 -25
- package/lib/middleware/netlify-edge/index.mjs +63 -71
- package/lib/middleware/node/index.mjs +297 -357
- package/lib/middleware/request-handler/index.mjs +110 -133
- package/lib/middleware/vercel-edge/index.mjs +82 -98
- package/lib/service-worker/index.mjs +12 -3
- package/lib/ssg/index.mjs +249 -289
- package/lib/vite/index.mjs +2344 -3030
- package/package.json +5 -5
- package/lib/chunks/use-functions.qwik.mjs +0 -23
|
@@ -1,98 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"X-Not-Found": url.pathname
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} catch (e) {
|
|
84
|
-
console.error(e);
|
|
85
|
-
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
86
|
-
status: 500,
|
|
87
|
-
headers: {
|
|
88
|
-
"Content-Type": "text/plain; charset=utf-8",
|
|
89
|
-
"X-Error": "cloudflare-pages"
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return onCloudflarePagesFetch;
|
|
1
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
2
|
+
import { setServerPlatform } from "@qwik.dev/core/server";
|
|
3
|
+
import { _TextEncoderStream_polyfill, getErrorHtml, isStaticPath, mergeHeadersCookies, requestHandler } from "@qwik.dev/router/middleware/request-handler";
|
|
4
|
+
/** @public */ function createQwikRouter(opts) {
|
|
5
|
+
try {
|
|
6
|
+
new globalThis.TextEncoderStream();
|
|
7
|
+
} catch {
|
|
8
|
+
globalThis.TextEncoderStream = _TextEncoderStream_polyfill;
|
|
9
|
+
}
|
|
10
|
+
if (opts.manifest) setServerPlatform(opts.manifest);
|
|
11
|
+
async function onCloudflarePagesFetch(request, env, ctx) {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(request.url);
|
|
14
|
+
if (isStaticPath(request.method, url)) return env.ASSETS.fetch(request);
|
|
15
|
+
const useCache = url.hostname !== "127.0.0.1" && url.hostname !== "localhost" && url.port === "" && request.method === "GET";
|
|
16
|
+
const cacheKey = new Request(url.href, request);
|
|
17
|
+
const cache = useCache ? await caches.open("custom:qwikrouter") : null;
|
|
18
|
+
if (cache) {
|
|
19
|
+
const cachedResponse = await cache.match(cacheKey);
|
|
20
|
+
if (cachedResponse) return cachedResponse;
|
|
21
|
+
}
|
|
22
|
+
const handledResponse = await requestHandler({
|
|
23
|
+
mode: "server",
|
|
24
|
+
locale: void 0,
|
|
25
|
+
url,
|
|
26
|
+
request,
|
|
27
|
+
env: { get(key) {
|
|
28
|
+
return env[key];
|
|
29
|
+
} },
|
|
30
|
+
getWritableStream: (status, headers, cookies, resolve) => {
|
|
31
|
+
const { readable, writable } = new TransformStream();
|
|
32
|
+
resolve(new Response(readable, {
|
|
33
|
+
status,
|
|
34
|
+
headers: mergeHeadersCookies(headers, cookies)
|
|
35
|
+
}));
|
|
36
|
+
return writable;
|
|
37
|
+
},
|
|
38
|
+
getClientConn: () => {
|
|
39
|
+
return {
|
|
40
|
+
ip: request.headers.get("CF-connecting-ip") || "",
|
|
41
|
+
country: request.headers.get("CF-IPCountry") || ""
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
platform: {
|
|
45
|
+
request,
|
|
46
|
+
env,
|
|
47
|
+
ctx
|
|
48
|
+
}
|
|
49
|
+
}, opts);
|
|
50
|
+
if (handledResponse) {
|
|
51
|
+
handledResponse.completion.then((completion) => {
|
|
52
|
+
if (completion) console.error(completion);
|
|
53
|
+
});
|
|
54
|
+
const response = await handledResponse.response;
|
|
55
|
+
if (response) {
|
|
56
|
+
if (response.ok && cache && response.headers.has("Cache-Control")) ctx.waitUntil(cache.put(cacheKey, response.clone()));
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const notFoundHtml = !request.headers.get("accept")?.includes("text/html") || isStaticPath(request.method || "GET", url) ? "Not Found" : getErrorHtml(404, "Not Found");
|
|
61
|
+
return new Response(notFoundHtml, {
|
|
62
|
+
status: 404,
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
65
|
+
"X-Not-Found": url.pathname
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error(e);
|
|
70
|
+
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
71
|
+
status: 500,
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
74
|
+
"X-Error": "cloudflare-pages"
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return onCloudflarePagesFetch;
|
|
95
80
|
}
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `createQwikRouter` instead. Will be removed in V3
|
|
83
|
+
* @public
|
|
84
|
+
*/ var createQwikCity = createQwikRouter;
|
|
98
85
|
export { createQwikCity, createQwikRouter };
|
|
@@ -1,129 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { n as MIME_TYPES, t as normalizeRequestUrl } from "../../chunks/url.mjs";
|
|
2
|
+
import { r as limitRequestBody } from "../../chunks/request-body-limit.mjs";
|
|
3
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
4
|
+
import { setServerPlatform } from "@qwik.dev/core/server";
|
|
5
|
+
import { isStaticPath, mergeHeadersCookies, requestHandler } from "@qwik.dev/router/middleware/request-handler";
|
|
6
|
+
import { extname, fromFileUrl, join } from "https://deno.land/std/path/mod.ts";
|
|
8
7
|
function getRequestUrl(request, opts, info) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
return normalizeRequestUrl(`${url.pathname}${url.search}${url.hash}`, origin);
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
const origin = opts.getOrigin?.(request, info) ?? Deno.env?.get?.("ORIGIN");
|
|
10
|
+
if (!origin) return url;
|
|
11
|
+
return normalizeRequestUrl(`${url.pathname}${url.search}${url.hash}`, origin);
|
|
15
12
|
}
|
|
16
|
-
function createQwikRouter(opts) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
} catch (e) {
|
|
111
|
-
console.error(e);
|
|
112
|
-
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
113
|
-
status: 500,
|
|
114
|
-
headers: {
|
|
115
|
-
"Content-Type": "text/plain; charset=utf-8",
|
|
116
|
-
"X-Error": "deno-server"
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
return {
|
|
122
|
-
router,
|
|
123
|
-
notFound,
|
|
124
|
-
staticFile
|
|
125
|
-
};
|
|
13
|
+
/** @public */ function createQwikRouter(opts) {
|
|
14
|
+
if (opts.manifest) setServerPlatform(opts.manifest);
|
|
15
|
+
const staticFolder = opts.static?.root ?? join(fromFileUrl(import.meta.url), "..", "..", "dist");
|
|
16
|
+
async function router(request, info) {
|
|
17
|
+
try {
|
|
18
|
+
const serverRequestEv = {
|
|
19
|
+
mode: "server",
|
|
20
|
+
locale: void 0,
|
|
21
|
+
url: getRequestUrl(request, opts, info),
|
|
22
|
+
env: Deno.env,
|
|
23
|
+
request: limitRequestBody(request, opts.requestBodyLimit),
|
|
24
|
+
getWritableStream: (status, headers, cookies, resolve) => {
|
|
25
|
+
const { readable, writable } = new TransformStream();
|
|
26
|
+
resolve(new Response(readable, {
|
|
27
|
+
status,
|
|
28
|
+
headers: mergeHeadersCookies(headers, cookies)
|
|
29
|
+
}));
|
|
30
|
+
return writable;
|
|
31
|
+
},
|
|
32
|
+
platform: { ssr: true },
|
|
33
|
+
getClientConn: () => {
|
|
34
|
+
return opts.getClientConn ? opts.getClientConn(request, info) : { ip: info.remoteAddr.hostname };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
38
|
+
if (handledResponse) {
|
|
39
|
+
handledResponse.completion.then((completion) => {
|
|
40
|
+
if (completion) console.error(completion);
|
|
41
|
+
});
|
|
42
|
+
const response = await handledResponse.response;
|
|
43
|
+
if (response) return response;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error(e);
|
|
48
|
+
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
49
|
+
status: 500,
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
52
|
+
"X-Error": "deno-server"
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated `router` handles 404 responses. Will be removed in V3. */ const notFound = async (_request) => {
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
const openStaticFile = async (url) => {
|
|
61
|
+
const pathname = url.pathname;
|
|
62
|
+
const fileName = pathname.slice(url.pathname.lastIndexOf("/"));
|
|
63
|
+
let filePath;
|
|
64
|
+
if (fileName.includes(".")) filePath = join(staticFolder, pathname);
|
|
65
|
+
else if (!globalThis.__NO_TRAILING_SLASH__) filePath = join(staticFolder, pathname + "index.html");
|
|
66
|
+
else filePath = join(staticFolder, pathname, "index.html");
|
|
67
|
+
return {
|
|
68
|
+
filePath,
|
|
69
|
+
content: await Deno.open(filePath, { read: true })
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const staticFile = async (request) => {
|
|
73
|
+
try {
|
|
74
|
+
const url = getRequestUrl(request, opts);
|
|
75
|
+
if (isStaticPath(request.method || "GET", url)) {
|
|
76
|
+
const { filePath, content } = await openStaticFile(url);
|
|
77
|
+
const ext = extname(filePath).replace(/^\./, "");
|
|
78
|
+
return new Response(content.readable, {
|
|
79
|
+
status: 200,
|
|
80
|
+
headers: {
|
|
81
|
+
"content-type": MIME_TYPES[ext] || "text/plain; charset=utf-8",
|
|
82
|
+
"Cache-Control": opts.static?.cacheControl || "max-age=3600"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
} catch (e) {
|
|
88
|
+
console.error(e);
|
|
89
|
+
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
90
|
+
status: 500,
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
93
|
+
"X-Error": "deno-server"
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
router,
|
|
100
|
+
notFound,
|
|
101
|
+
staticFile
|
|
102
|
+
};
|
|
126
103
|
}
|
|
127
|
-
|
|
128
|
-
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use `createQwikRouter` instead. Will be removed in V3
|
|
106
|
+
* @public
|
|
107
|
+
*/ var createQwikCity = createQwikRouter;
|
|
129
108
|
export { createQwikCity, createQwikRouter };
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { createQwikRouter as createQwikRouter$1 } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return staticFile(req, res, () => {
|
|
19
|
-
router(req, res, () => {
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
return qwikApp;
|
|
1
|
+
import { createQwikRouter as createQwikRouter$1 } from "@qwik.dev/router/middleware/node";
|
|
2
|
+
/** @public */ function createQwikRouter(opts) {
|
|
3
|
+
const { staticFile, router } = createQwikRouter$1({
|
|
4
|
+
render: opts.render,
|
|
5
|
+
manifest: opts.manifest,
|
|
6
|
+
static: { cacheControl: "public, max-age=31557600" },
|
|
7
|
+
getOrigin(req) {
|
|
8
|
+
if (process.env.IS_OFFLINE) return `http://${req.headers.host}`;
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const qwikApp = (req, res) => {
|
|
13
|
+
return staticFile(req, res, () => {
|
|
14
|
+
router(req, res, () => {});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
return qwikApp;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `createQwikRouter` instead. Will be removed in V3
|
|
21
|
+
* @public
|
|
22
|
+
*/ var createQwikCity = createQwikRouter;
|
|
27
23
|
export { createQwikCity, createQwikRouter };
|
|
@@ -1,73 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
61
|
-
status: 500,
|
|
62
|
-
headers: {
|
|
63
|
-
"Content-Type": "text/plain; charset=utf-8",
|
|
64
|
-
"X-Error": "netlify-edge"
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return onNetlifyEdgeRequest;
|
|
1
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
2
|
+
import { setServerPlatform } from "@qwik.dev/core/server";
|
|
3
|
+
import { getErrorHtml, isStaticPath, mergeHeadersCookies, requestHandler } from "@qwik.dev/router/middleware/request-handler";
|
|
4
|
+
/** @public */ function createQwikRouter(opts) {
|
|
5
|
+
if (opts.manifest) setServerPlatform(opts.manifest);
|
|
6
|
+
async function onNetlifyEdgeRequest(request, context) {
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
if (isStaticPath(request.method, url) || url.pathname.startsWith("/.netlify")) return context.next();
|
|
10
|
+
const serverRequestEv = {
|
|
11
|
+
mode: "server",
|
|
12
|
+
locale: void 0,
|
|
13
|
+
url,
|
|
14
|
+
env: Deno.env,
|
|
15
|
+
request,
|
|
16
|
+
getWritableStream: (status, headers, cookies, resolve) => {
|
|
17
|
+
const { readable, writable } = new TransformStream();
|
|
18
|
+
resolve(new Response(readable, {
|
|
19
|
+
status,
|
|
20
|
+
headers: mergeHeadersCookies(headers, cookies)
|
|
21
|
+
}));
|
|
22
|
+
return writable;
|
|
23
|
+
},
|
|
24
|
+
getClientConn: () => {
|
|
25
|
+
return {
|
|
26
|
+
ip: context.ip,
|
|
27
|
+
country: context.geo.country?.code
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
platform: context
|
|
31
|
+
};
|
|
32
|
+
const handledResponse = await requestHandler(serverRequestEv, opts);
|
|
33
|
+
if (handledResponse) {
|
|
34
|
+
handledResponse.completion.then((completion) => {
|
|
35
|
+
if (completion) console.error(completion);
|
|
36
|
+
});
|
|
37
|
+
const response = await handledResponse.response;
|
|
38
|
+
if (response) return response;
|
|
39
|
+
}
|
|
40
|
+
const notFoundHtml = !request.headers.get("accept")?.includes("text/html") || isStaticPath(request.method || "GET", url) ? "Not Found" : getErrorHtml(404, "Not Found");
|
|
41
|
+
return new Response(notFoundHtml, {
|
|
42
|
+
status: 404,
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
45
|
+
"X-Not-Found": url.pathname
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error(e);
|
|
50
|
+
return new Response(isDev ? String(e || "Error") : "Internal Server Error", {
|
|
51
|
+
status: 500,
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
54
|
+
"X-Error": "netlify-edge"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return onNetlifyEdgeRequest;
|
|
70
60
|
}
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `createQwikRouter` instead. Will be removed in V3
|
|
63
|
+
* @public
|
|
64
|
+
*/ var createQwikCity = createQwikRouter;
|
|
73
65
|
export { createQwikCity, createQwikRouter };
|