Something went wrong. Try again.
🌿 Collaborative wiki on ATProto forked from juprodh.me/lichen.wiki
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738import { isAuthEnabled } from "../atproto/env.ts";import { LIMITS } from "../lib/limits.ts";import { initHighlighter } from "../lib/markdown/highlight-plugin.ts";import { buildApp } from "./app.ts";import { deleteStaleDrafts } from "./db/queries/index.ts";
if (!isAuthEnabled()) { console.warn( "ATProto OAuth not configured (PUBLIC_URL / OAUTH_PRIVATE_KEY_PATH missing). Running in dev mode without auth.", );}
// Sweep abandoned collab drafts older than 30 days — on boot, then daily.const DRAFT_GC_INTERVAL_MS = 24 * 60 * 60 * 1000;function sweepStaleDrafts(): void { try { const removed = deleteStaleDrafts(); if (removed > 0) console.log(`Swept ${removed} stale collab draft(s)`); } catch (err) { console.error("Draft sweep failed:", err); }}sweepStaleDrafts();setInterval(sweepStaleDrafts, DRAFT_GC_INTERVAL_MS).unref();
await initHighlighter();
// Loopback by default — Caddy proxies localhost:PORT, so the appview must never// be reachable directly from the internet (bypassing TLS and the CDN). Inside a// container set HOST=0.0.0.0: there the publish mapping is what limits exposure.const app = buildApp().listen({ port: Number(process.env["PORT"] ?? 3000), hostname: process.env["HOST"] ?? "127.0.0.1", maxRequestBodySize: LIMITS.maxRequestBodyBytes,});
console.log(`Lichen running at http://localhost:${app.server?.port}`);