Something went wrong. Try again.
Connected apps with 3rd-party data hosts
jsr.io/@civility
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#!/usr/bin/env -S deno run -A/** * Civility server — Docker (SQLite + local filesystem) entry point. * * Single-resource deployment: ONE container plus ONE mounted volume. The * database (SQLite) and blobs both live on disk under DATA_DIR — no external * Postgres, no S3. Simplest possible production self-host; the trade-off is * that it's single-instance only (you can't run multiple replicas against the * same SQLite file). For horizontal scaling, use ../postgres/. * * - DATA_DIR → directory holding the SQLite DB + blobs (default /data) * - PORT → bind port (default 8080) * - CIVILITY_ADMIN_TOKEN, CIVILITY_ADMIN_EMAILS, CIVILITY_AUTH_SECRET → optional * * The `dialect: 'sqlite'` shorthand builds the SQLite auth/db/store adapters * and runs migrations for you. Email transport is configured at runtime in the * admin panel (/admin/email) — see ../../features/admin.md — not via env. */import { createManager } from '@civility/hono'import { createFsObjectStorage } from '@civility/hono/storage/fs'
const port = Number(Deno.env.get('PORT') ?? '8080')const adminToken = Deno.env.get('CIVILITY_ADMIN_TOKEN')// Operator accounts (spec §16.2.2): comma-separated emails whose dashboard// sessions open /admin.const adminEmails = Deno.env.get('CIVILITY_ADMIN_EMAILS') ?.split(',').map((e) => e.trim()).filter(Boolean)const dataDir = Deno.env.get('DATA_DIR') ?? '/data'
// Ensure the data directory exists (the volume mount point).await Deno.mkdir(dataDir, { recursive: true })
// Blobs on the local filesystem, served by Civility at /blobs/*.const objectStorage = createFsObjectStorage({ basePath: `${dataDir}/blobs` })
// CIVILITY_AUTH_SECRET is read from the environment by createManager.const app = (await createManager({ adapters: { objectStorage }, options: { adminToken, adminEmails, backend: { dialect: 'sqlite', dbPath: `${dataDir}/civility.db`, }, },})).buildApp()
console.log(`Civility server listening on :${port}`)console.log(`Adapters: sqlite/fs (data dir: ${dataDir})`)Deno.serve({ port, hostname: '0.0.0.0' }, app.fetch)