diff --git a/.env.example b/.env.example index b1eb16c..0be65c6 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ PORT=3000 DATA_DIR=./data -MAX_FILE_SIZE=524288000 -MAX_TTL=30d +MAX_FILE_SIZE=100000000 +MAX_TTL=7d diff --git a/package.json b/package.json index 48fa621..92a7f39 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "drop", "private": true, "type": "module", - "module": "src/index.ts", "scripts": { "dev": "cd web && bun run dev & bun run --hot src/index.ts", "build": "cd web && bun install && bun run build", diff --git a/src/config.ts b/src/config.ts index d81bf7a..3c4e12f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,6 @@ export const config = { port: parseInt(process.env.PORT || "3000"), dataDir: process.env.DATA_DIR || "./data", - maxFileSize: parseInt(process.env.MAX_FILE_SIZE || "524288000"), // 500MB - maxTtl: process.env.MAX_TTL || "30d", + maxFileSize: parseInt(process.env.MAX_FILE_SIZE || "100000000"), + maxTtl: process.env.MAX_TTL || "7d", }; diff --git a/src/routes/file.ts b/src/file.ts similarity index 95% rename from src/routes/file.ts rename to src/file.ts index f5cd8d2..597eda9 100644 --- a/src/routes/file.ts +++ b/src/file.ts @@ -1,7 +1,7 @@ import { Hono } from "hono"; -import { config } from "../config.ts"; -import { createFile, getFile, peekFile, unlinkFile } from "../db.ts"; +import { config } from "./config.ts"; +import { createFile, getFile, peekFile, unlinkFile } from "./db.ts"; const DURATION_UNITS: Record = { s: 1, diff --git a/src/index.ts b/src/index.ts index f7037f0..12ce901 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,12 +3,19 @@ import { serveStatic } from "hono/bun"; import { config } from "./config.ts"; import { cleanExpired } from "./db.ts"; -import file from "./routes/file.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.use("/*", serveStatic({ root: "./web/dist" })); // SPA catch-all: serve index.html for unmatched routes