feat: migrate frontend to Astro + expand AI moderation + backend admin/runtime config

Frontend:
- migrate from Vite to Astro (astro.config.mjs, pages/, layouts/)
- add admin panel, settings page, command palette, error boundary
- refactor App.tsx, MascotChatbot, Sidebar, Header, DashboardLayout
- update API client, WebSocket, auth, dashboard features

Backend:
- add admin module and config routes
- refactor middlewares, Redis connection, WebSocket server/bridge
- add runtime config loader

Discord Gateway:
- refactor AI moderation: circuit breaker, concurrency limiter, fallback processor
- add media analysis client, Seaxng search, user profile learner
- add new drizzle migration

Shared:
- extend database schema, add new config fields
This commit is contained in:
asepharyana
2026-07-02 00:02:41 +07:00
parent d5c22a3959
commit d59b59a7a7
91 changed files with 11165 additions and 674 deletions
@@ -12,19 +12,25 @@ let rawPool: Pool | null = null;
/**
* Initialize the PostgreSQL database connection.
* When called from a Piscina worker thread, pool min/max are reduced to
* avoid exhausting PG connections across many worker processes.
*/
export async function initializeDatabase() {
if (db !== null) {
return db;
}
const isWorker = typeof process.env.PISCINA_WORKER !== "undefined";
const poolMin = isWorker ? 1 : config.POSTGRES_POOL_MIN;
const poolMax = isWorker ? 2 : config.POSTGRES_POOL_MAX;
let pool: Pool;
if (config.DATABASE_URL) {
pool = new Pool({
connectionString: config.DATABASE_URL,
min: config.POSTGRES_POOL_MIN,
max: config.POSTGRES_POOL_MAX,
min: poolMin,
max: poolMax,
});
} else {
pool = new Pool({
@@ -33,8 +39,8 @@ export async function initializeDatabase() {
user: config.POSTGRES_USER,
password: config.POSTGRES_PASSWORD,
database: config.POSTGRES_DB,
min: config.POSTGRES_POOL_MIN,
max: config.POSTGRES_POOL_MAX,
min: poolMin,
max: poolMax,
});
}