add bun backend and add upload bitstream component
This commit is contained in:
0
server/DataBase.ts
Normal file
0
server/DataBase.ts
Normal file
39
server/index.ts
Normal file
39
server/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { serve } from "bun";
|
||||
|
||||
serve({
|
||||
port: 3001,
|
||||
// hostname: "fpga.swordlost.com",
|
||||
routes: {
|
||||
// Static routes
|
||||
"/api/status": new Response("OK"),
|
||||
|
||||
// Dynamic routes
|
||||
"/users/:id": req => {
|
||||
return new Response(`Hello User ${req.params.id}!`);
|
||||
},
|
||||
|
||||
// Per-HTTP method handlers
|
||||
"/api/posts": {
|
||||
GET: () => new Response("List posts"),
|
||||
POST: async req => {
|
||||
const body = await req.json();
|
||||
|
||||
if (body !== null) {
|
||||
return Response.json({ created: true, ...body });
|
||||
} else {
|
||||
return Response.json({})
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
// Wildcard route for all routes that start with "/api/" and aren't otherwise matched
|
||||
"/api/*": Response.json({ message: "Not found" }, { status: 404 }),
|
||||
|
||||
// Serve a file by buffering it in memory
|
||||
// "/favicon.ico": new Response(await Bun.file("../public/favicon.icon").bytes(), {
|
||||
// headers: {
|
||||
// "Content-Type": "image/x-icon",
|
||||
// },
|
||||
// }),
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user