refactor: 🚚 Organize code into sub-packages, instead of a single large package

This commit is contained in:
Jesse Wierzbinski 2025-06-15 04:38:20 +02:00
parent 79742f47dc
commit a6d3ebbeef
No known key found for this signature in database
366 changed files with 942 additions and 833 deletions

41
packages/api/setup.ts Normal file
View file

@ -0,0 +1,41 @@
import { getLogger } from "@logtape/logtape";
import { Note, setupDatabase } from "@versia/kit/db";
import { config } from "@versia-server/config";
import { configureLoggers } from "@/loggers";
import { connection } from "@/redis.ts";
import { searchManager } from "../../classes/search/search-manager.ts";
const timeAtStart = performance.now();
await configureLoggers();
const serverLogger = getLogger("server");
console.info(`
`);
serverLogger.info`Starting Versia Server...`;
await setupDatabase();
if (config.search.enabled) {
await searchManager.connect();
}
// Check if database is reachable
const postCount = await Note.getCount();
serverLogger.info`Versia Server started at ${config.http.bind}:${config.http.bind_port} in ${(performance.now() - timeAtStart).toFixed(0)}ms`;
serverLogger.info`Database is online, now serving ${postCount} posts`;
// Check if Redis is reachable
await connection.ping();
serverLogger.info`Redis is online`;