Nintron
04/08/2023, 9:08 PMts
import type { PageServerLoad } from "./$types";
export const load = (async () => {
const response = await fetch("https://catfact.ninja/fact");
return await response.json();
}) satisfies PageServerLoad;
Third, I've seen a few people say network time isn't counted in Bundled Workers, but I can't seem to find this on the actual Docs, is this the case?zegevlier
04/08/2023, 9:15 PMzegevlier
04/08/2023, 9:16 PMNintron
04/08/2023, 9:18 PMUnsmart | Tech debt
04/08/2023, 9:19 PMreturn fetch("https://catfact.ninja/fact")
instead of parsing the json on the server the cpu time should basically be 0ms since the cpu doesnt really do anything.
Also the cpu time is very forgiving it will allow you to go over pretty frequently but you should aim to keep the average as low as possible.kian
04/08/2023, 9:20 PMkian
04/08/2023, 9:20 PMkian
04/08/2023, 9:23 PMkian
04/08/2023, 9:23 PMNintron
04/08/2023, 9:23 PMUnsmart | Tech debt
04/08/2023, 9:24 PMNintron
04/08/2023, 9:24 PMkian
04/08/2023, 9:24 PMkian
04/08/2023, 9:25 PMkian
04/08/2023, 9:25 PMkian
04/08/2023, 9:25 PMNintron
04/08/2023, 9:33 PMjilio
04/09/2023, 6:36 AMjilio
04/09/2023, 6:41 AMkian
04/09/2023, 6:42 AMwrangler.toml
isn't considered by Functionskian
04/09/2023, 6:43 AM/functions
is for the path-based routing - i.e /functions/hello.ts
would map to example.com/hello
kian
04/09/2023, 6:43 AM_worker.js
and put it in the output directoryjilio
04/09/2023, 6:46 AMkian
04/09/2023, 6:49 AM--bundle
to wrangler pages publish
and you can just have an 'index' _worker.js
that imports the rest as-needed if you wantkian
04/09/2023, 6:49 AM_worker.js
jilio
04/09/2023, 6:55 AMjilio
04/09/2023, 10:35 AM_worker.js
file. The error message reads: "Error: Failed to publish your Function. Got error: multipart uploads must contain a readable body_part or main_module."
Do you have any suggestions on how to resolve this issue?
I'm using esbuild to bundle my worker like this esbuild src/index.ts --bundle --outfile=_worker.js
jaymakes11
04/10/2023, 10:25 AMWalshy | Pages
04/10/2023, 10:33 AMenv
e.g:
js
export function onRequest({ env }) {
return new Response(env.SECRET);
}
Where the secret is literally called "SECRET"