-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Hi there!
Yet started to dive into all this CF stuff and wondering if such feature as Static Assets will be supported?
Planning to use it with newest Framework Templates feature (especially Vue) so it'll be great to support it.
I have tried to figure out how to deal with it but ended up keeping on js level like so:
// worker.mjs
import * as imports from "./shim.mjs";
import mod from "./app.wasm";
imports.init(mod);
// export default { fetch: imports.fetch, scheduled: imports.scheduled, queue: imports.queue };
export default {
scheduled: imports.scheduled,
queue: imports.queue,
fetch: async (request, env) => {
let resp = await imports.fetch(request, env);
if (resp != undefined) {
return resp;
}
return env.ASSETS.fetch(request);
}
};but because fetch returns and Response object any way it's not possible to bypass it to env.ASSETS correctly.
Following approach working, but don't looks like it's a valid:
// worker.mjs
import * as imports from "./shim.mjs";
import mod from "./app.wasm";
imports.init(mod);
// export default { fetch: imports.fetch, scheduled: imports.scheduled, queue: imports.queue };
export default {
scheduled: imports.scheduled,
queue: imports.queue,
fetch: async (request, env) => {
let resp = await imports.fetch(request, env);
if (resp.status == 404) {
return env.ASSETS.fetch(request);
}
return resp;
}
};As for go level - i don't figured out how to handle it =\
Also it'll be great to support typescript if possible, but it not really necessary because the only js code needed for workers is linking and generated dynamically, so not a big issue for now.
syumai
Metadata
Metadata
Assignees
Labels
No labels