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

View file

@ -1,8 +1,10 @@
import type { Hook } from "@hono/zod-validator";
import { getLogger } from "@logtape/logtape";
import type { RolePermission } from "@versia/client/schemas";
import { ApiError } from "@versia/kit";
import { Application, db, Emoji, Note, Token, User } from "@versia/kit/db";
import { Challenges } from "@versia/kit/tables";
import { config } from "@versia-server/config";
import { extractParams, verifySolution } from "altcha-lib";
import { SHA256 } from "bun";
import chalk from "chalk";
@ -26,9 +28,7 @@ import {
import { type ParsedQs, parse } from "qs";
import { type ZodAny, type ZodError, z } from "zod";
import { fromZodError } from "zod-validation-error";
import { ApiError } from "~/classes/errors/api-error";
import type { AuthData } from "~/classes/functions/user";
import { config } from "~/config.ts";
import type { HonoEnv } from "~/types/api";
export const apiRoute = (fn: (app: Hono<HonoEnv>) => void): typeof fn => fn;

View file

@ -1,6 +1,7 @@
import { createBullBoard } from "@bull-board/api";
import { BullMQAdapter } from "@bull-board/api/bullMQAdapter";
import { HonoAdapter } from "@bull-board/hono";
import { config } from "@versia-server/config";
import type { Hono } from "hono";
import { serveStatic } from "hono/bun";
import { deliveryQueue } from "~/classes/queues/delivery";
@ -9,7 +10,6 @@ import { inboxQueue } from "~/classes/queues/inbox";
import { mediaQueue } from "~/classes/queues/media";
import { pushQueue } from "~/classes/queues/push";
import { relationshipQueue } from "~/classes/queues/relationships";
import { config } from "~/config.ts";
import pkg from "~/package.json" with { type: "json" };
import type { HonoEnv } from "~/types/api";
@ -43,6 +43,5 @@ export const applyToHono = (app: Hono<HonoEnv>): void => {
});
serverAdapter.setBasePath("/admin/queues");
// @ts-expect-error idk why it's like this
app.route("/admin/queues", serverAdapter.registerPlugin());
};

View file

@ -1,9 +1,9 @@
import { db } from "@versia/kit/db";
import { Challenges } from "@versia/kit/tables";
import { config } from "@versia-server/config";
import { createChallenge } from "altcha-lib";
import type { Challenge } from "altcha-lib/types";
import { randomUUIDv7 } from "bun";
import { config } from "~/config.ts";
export const generateChallenge = async (
maxNumber?: number,

View file

@ -1,8 +1,8 @@
import type { ContentFormatSchema } from "@versia/sdk/schemas";
import { config } from "@versia-server/config";
import { htmlToText as htmlToTextLib } from "html-to-text";
import { lookup } from "mime-types";
import type { z } from "zod";
import { config } from "~/config.ts";
import type { ContentFormatSchema } from "~/packages/sdk/schemas";
export const getBestContentType = (
content?: z.infer<typeof ContentFormatSchema> | null,

View file

@ -8,8 +8,8 @@ import {
type LogLevel,
type LogRecord,
} from "@logtape/logtape";
import { config } from "@versia-server/config";
import chalk from "chalk";
import { config } from "~/config.ts";
// config.logging.log_file_path is a path to a file, create the directory if it doesn't exist
await mkdir(dirname(config.logging.log_file_path), { recursive: true });

View file

@ -1,5 +1,5 @@
import { config } from "@versia-server/config";
import IORedis from "ioredis";
import { config } from "~/config.ts";
export const connection = new IORedis({
host: config.redis.queue.host,

View file

@ -1,10 +1,8 @@
import { Media, Note, type User } from "@versia/kit/db";
import { Notes } from "@versia/kit/tables";
import { config } from "@versia-server/config";
import { and, eq, inArray } from "drizzle-orm";
import { Feed } from "feed";
import { Media } from "~/classes/database/media";
import { Note } from "~/classes/database/note";
import type { User } from "~/classes/database/user";
import { config } from "~/config";
import { Notes } from "~/drizzle/schema";
export const getFeed = async (user: User, page = 0): Promise<Feed> => {
const notes = await Note.manyFromSql(

View file

@ -1,6 +1,6 @@
import { ProxiableUrl } from "@versia-server/config";
import { stringifyEntitiesLight } from "stringify-entities";
import xss, { type IFilterXSSOptions } from "xss";
import { ProxiableUrl } from "~/classes/media/url.ts";
export const sanitizedHtmlStrip = (html: string): Promise<string> => {
return sanitizeHtml(html, {

View file

@ -1,6 +1,6 @@
import * as Sentry from "@sentry/bun";
import { config } from "@versia-server/config";
import { env } from "bun";
import { config } from "~/config.ts";
import pkg from "~/package.json" with { type: "json" };
const sentryInstance =

View file

@ -1,7 +1,7 @@
import type { ConfigSchema } from "@versia-server/config/schema";
import { type Server, serve } from "bun";
import type { Hono } from "hono";
import type { z } from "zod";
import type { ConfigSchema } from "~/classes/config/schema.ts";
import type { HonoEnv } from "~/types/api";
import { debugResponse } from "./api.ts";