File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,11 +20,31 @@ export const runBunCompilation = async () => {
2020 await Bun . write ( filesystem ! . dist + "worker.ts" , `
2121 import { serve } from 'bun';
2222 import index from './index.html';
23+ import { dirname } from 'path';
24+
25+ const BASE_MEDIA_PATH = "/media/";
26+ const EXE_DIR = dirname(process.execPath);
2327
2428 const server = serve({
2529 routes: {
2630 '/': index,
2731 },
32+ fetch(req) {
33+ const filepath = new URL(req.url).pathname;
34+ if (req.method === 'GET') {
35+ if (filepath.startsWith('/favicon')) {
36+ const filePath = \`\${ EXE_DIR }\${ BASE_MEDIA_PATH }favicon.svg\`;
37+ const file = Bun.file(filePath);
38+ return new Response(file);
39+ } else if (filepath.startsWith(BASE_MEDIA_PATH)) {
40+ const filePath = \`\${ EXE_DIR }\${ new URL(req.url).pathname }\`;
41+ const file = Bun.file(filePath);
42+ return new Response(file);
43+ }
44+ }
45+
46+ return new Response('Not Found', { status: 404 });
47+ },
2848 });
2949 ` ) ;
3050
You can’t perform that action at this time.
0 commit comments