This repository has been archived on 2025-03-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cetra/examples/server.js

18 lines
487 B
JavaScript

export default {
port: Bun.env.BUN_PORT || Bun.env.APP_PORT || 3000,
async fetch(req) {
const url = new URL(req.url);
if (url.pathname == '/main.js') {
await Bun.build({
entrypoints: ['./src/main.js'],
outdir: '.',
});
return new Response(Bun.file('./main.js'), {
headers: { 'Cache-Control': 'no-cache' },
});
}
if (url.pathname == '/') return new Response(Bun.file('./index.html'));
return new Response('ERR 404: Not Found', { status: 404 });
},
};