mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
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:
parent
d4afd84019
commit
54fd81f076
118 changed files with 3892 additions and 5291 deletions
|
|
@ -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>';
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue