Something went wrong. Try again.
zero-knowledge file sharing
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import { Hono } from "hono";import { serveStatic } from "hono/bun";
import { config } from "./config.ts";import { cleanExpired } from "./db.ts";import file from "./file.ts";
const app = new Hono();
app.route("/api/file", file);
app.get("/api/info", (c) => { return c.json({ maxFileSize: config.maxFileSize, maxTtl: config.maxTtl, });});
app.get("/sw.js", (c) => new Response(Bun.file("web/dist/sw.js"), { headers: { "Content-Type": "application/javascript", "Service-Worker-Allowed": "/", }, }),);
app.use("/*", serveStatic({ root: "./web/dist" }));
// SPA catch-all: serve index.html for unmatched routesapp.get("/*", () => { return new Response(Bun.file("web/dist/index.html"), { headers: { "Content-Type": "text/html; charset=utf-8" }, });});
// Clean expired uploads every 5 minutessetInterval(cleanExpired, 5 * 60 * 1000);
const port = config.port;console.log(`Server running on http://localhost:${port}`);
export default { port, maxRequestBodySize: config.maxFileSize, fetch: app.fetch,};