Rebuild the hub on Bun: Elysia API, Better Auth, Drizzle, Next.js website
CI / test (push) Successful in 30s
CI / test (push) Successful in 30s
The hub becomes a Bun monorepo: apps/api (Elysia, Better Auth for accounts, roles, bans, proxy device sign-in and JWT keys; tagline linking, presence and the console as before), packages/db (Drizzle; Postgres in production, PGlite in development and tests), and the Next.js website from apps/web. Self-hostable with docker compose; the website deploys to Vercel-style hosts, the API to any that runs Bun or containers. The first version, in Go, is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
64c552330b
commit
7a06ba49c3
59 files changed
+2640
-3523
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// Runs the hub's API. Configuration (environment):
|
||||
// DATABASE_URL postgres://... (default: PGlite files in ./data/db, for development)
|
||||
// AUTH_SECRET at least 32 random characters (required unless NODE_ENV is development)
|
||||
// API_URL the API's address as the website and proxies reach it (default http://localhost:4101)
|
||||
// WEB_URL the website's address (default http://localhost:4100)
|
||||
// PORT default 4101
|
||||
import { openDatabase } from "@t5de/db";
|
||||
import { createApp } from "./app";
|
||||
import { createAuth } from "./auth";
|
||||
import { ImvuClient } from "./imvu";
|
||||
|
||||
const env = process.env;
|
||||
const dev = env.NODE_ENV !== "production";
|
||||
const port = Number(env.PORT ?? 4101);
|
||||
const secret = env.AUTH_SECRET ?? (dev ? "development-secret-not-for-production-use" : "");
|
||||
if (secret.length < 32) {
|
||||
console.error("AUTH_SECRET must be at least 32 characters");
|
||||
process.exit(1);
|
||||
}
|
||||
const apiURL = env.API_URL ?? `http://localhost:${port}`;
|
||||
const webURL = env.WEB_URL ?? "http://localhost:4100";
|
||||
|
||||
const { db } = await openDatabase(env.DATABASE_URL ?? "./data/db");
|
||||
const auth = createAuth(db, { apiURL, webURL, secret });
|
||||
const { app } = createApp({ db, auth, imvu: new ImvuClient() });
|
||||
app.listen({ port, hostname: env.HOST ?? "0.0.0.0" });
|
||||
console.log(`t5de-hub API on ${apiURL} (website ${webURL})`);
|
||||
Reference in new issue
Block a user