refactor(config): ♻️ Redo config structure from scratch, simplify validation code, improve checks, add support for loading sensitive data from paths

This commit is contained in:
Jesse Wierzbinski 2025-02-15 02:47:29 +01:00
parent d4afd84019
commit 54fd81f076
No known key found for this signature in database
118 changed files with 3892 additions and 5291 deletions

View file

@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it, mock } from "bun:test";
import sharp from "sharp";
import type { Config } from "~/packages/config-manager/config.type";
import type { config } from "~/config.ts";
import { convertImage } from "./image-conversion.ts";
describe("ImageConversionPreprocessor", () => {
let mockConfig: Config;
let mockConfig: typeof config;
beforeEach(() => {
mockConfig = {
@ -15,9 +15,9 @@ describe("ImageConversionPreprocessor", () => {
convert_vector: false,
},
},
} as Config;
} as unknown as typeof config;
mock.module("~/packages/config-manager/index.ts", () => ({
mock.module("~/config.ts", () => ({
config: mockConfig,
}));
});
@ -59,7 +59,7 @@ describe("ImageConversionPreprocessor", () => {
});
it("should convert SVG when convert_vector is true", async () => {
mockConfig.media.conversion.convert_vector = true;
mockConfig.media.conversion.convert_vectors = true;
const svgContent =
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="red"/></svg>';

View file

@ -4,7 +4,7 @@
*/
import sharp from "sharp";
import { config } from "~/packages/config-manager/index.ts";
import { config } from "~/config.ts";
/**
* Supported input media formats.
@ -39,7 +39,7 @@ const supportedOutputFormats = [
const isConvertible = (file: File): boolean => {
if (
file.type === "image/svg+xml" &&
!config.media.conversion.convert_vector
!config.media.conversion.convert_vectors
) {
return false;
}