diff --git a/apps/server/src/attachmentPaths.ts b/apps/server/src/attachmentPaths.ts index cb0e8e43a8..f9fb605669 100644 --- a/apps/server/src/attachmentPaths.ts +++ b/apps/server/src/attachmentPaths.ts @@ -1,14 +1,10 @@ import path from "node:path"; -import { ATTACHMENTS_ROUTE_PREFIX } from "./projectFaviconRoute.ts"; +import { ATTACHMENTS_ROUTE_PREFIX } from "./imageMime.ts"; export function normalizeAttachmentRelativePath(rawRelativePath: string): string | null { const normalized = path.normalize(rawRelativePath).replace(/^[/\\]+/, ""); - if ( - normalized.length === 0 || - normalized.startsWith("..") || - normalized.includes("\0") - ) { + if (normalized.length === 0 || normalized.startsWith("..") || normalized.includes("\0")) { return null; } return normalized.replace(/\\/g, "/"); diff --git a/apps/server/src/imageMime.ts b/apps/server/src/imageMime.ts index 249deff0ca..f808cefdcd 100644 --- a/apps/server/src/imageMime.ts +++ b/apps/server/src/imageMime.ts @@ -1,5 +1,7 @@ import Mime from "@effect/platform-node/Mime"; +export const ATTACHMENTS_ROUTE_PREFIX = "/attachments"; + export const IMAGE_EXTENSION_BY_MIME_TYPE: Record = { "image/avif": ".avif", "image/bmp": ".bmp", diff --git a/apps/server/src/orchestration/Layers/ProjectionPipeline.ts b/apps/server/src/orchestration/Layers/ProjectionPipeline.ts index 15093a62d6..45e6196b50 100644 --- a/apps/server/src/orchestration/Layers/ProjectionPipeline.ts +++ b/apps/server/src/orchestration/Layers/ProjectionPipeline.ts @@ -38,8 +38,11 @@ import { type OrchestrationProjectionPipelineShape, } from "../Services/ProjectionPipeline.ts"; import { attachmentRouteToRelativePath } from "../../attachmentPaths.ts"; -import { ATTACHMENTS_ROUTE_PREFIX } from "../../projectFaviconRoute.ts"; -import { inferImageExtension, parseBase64DataUrl } from "../../imageMime.ts"; +import { + ATTACHMENTS_ROUTE_PREFIX, + inferImageExtension, + parseBase64DataUrl, +} from "../../imageMime.ts"; export const ORCHESTRATION_PROJECTOR_NAMES = { projects: "projection.projects", diff --git a/apps/server/src/projectFaviconRoute.ts b/apps/server/src/projectFaviconRoute.ts index 4f4315791d..4d66f0e86f 100644 --- a/apps/server/src/projectFaviconRoute.ts +++ b/apps/server/src/projectFaviconRoute.ts @@ -2,8 +2,6 @@ import fs from "node:fs"; import http from "node:http"; import path from "node:path"; -export const ATTACHMENTS_ROUTE_PREFIX = "/attachments"; - const FAVICON_MIME_TYPES: Record = { ".png": "image/png", ".jpg": "image/jpeg", diff --git a/apps/server/src/wsServer.ts b/apps/server/src/wsServer.ts index ac978806d2..85991dc2bb 100644 --- a/apps/server/src/wsServer.ts +++ b/apps/server/src/wsServer.ts @@ -54,8 +54,9 @@ import { clamp } from "effect/Number"; import { Open } from "./open"; import { ServerConfig } from "./config"; import { GitCore } from "./git/Services/GitCore.ts"; -import { ATTACHMENTS_ROUTE_PREFIX, tryHandleProjectFaviconRequest } from "./projectFaviconRoute"; +import { tryHandleProjectFaviconRequest } from "./projectFaviconRoute"; import { normalizeAttachmentRelativePath, resolveAttachmentRelativePath } from "./attachmentPaths"; +import { ATTACHMENTS_ROUTE_PREFIX } from "./imageMime.ts"; /** * ServerShape - Service API for server lifecycle control.