From 5fd9768a80c5fccf5d9f69d0b7b3d142a621f620 Mon Sep 17 00:00:00 2001 From: James Brink Date: Mon, 29 Dec 2025 12:29:01 -0700 Subject: [PATCH] fix: address PR review feedback - Use consistent schema syntax (string? instead of key?) - Remove config tests per maintainer request --- app/server/core/__tests__/config.test.ts | 74 ------------------------ app/server/core/config.ts | 2 +- 2 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 app/server/core/__tests__/config.test.ts diff --git a/app/server/core/__tests__/config.test.ts b/app/server/core/__tests__/config.test.ts deleted file mode 100644 index 8dbf0720..00000000 --- a/app/server/core/__tests__/config.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { test, describe, expect } from "bun:test"; -import { type } from "arktype"; - -// Re-create the schema to test in isolation (avoids side effects from importing config) -const createEnvSchema = () => - type({ - NODE_ENV: type.enumerated("development", "production", "test").default("production"), - SERVER_IP: 'string = "localhost"', - SERVER_IDLE_TIMEOUT: 'string.integer.parse = "60"', - RESTIC_HOSTNAME: "string = 'zerobyte'", - PORT: 'string.integer.parse = "4096"', - "MIGRATIONS_PATH?": "string", - }).pipe((s) => ({ - __prod__: s.NODE_ENV === "production", - environment: s.NODE_ENV, - serverIp: s.SERVER_IP, - serverIdleTimeout: s.SERVER_IDLE_TIMEOUT, - resticHostname: s.RESTIC_HOSTNAME, - port: s.PORT, - migrationsPath: s.MIGRATIONS_PATH, - })); - -describe("config", () => { - describe("PORT", () => { - test("should default to 4096 when not set", () => { - const schema = createEnvSchema(); - const result = schema({}); - - expect(result).not.toBeInstanceOf(type.errors); - if (!(result instanceof type.errors)) { - expect(result.port).toBe(4096); - } - }); - - test("should parse PORT as integer", () => { - const schema = createEnvSchema(); - const result = schema({ PORT: "8080" }); - - expect(result).not.toBeInstanceOf(type.errors); - if (!(result instanceof type.errors)) { - expect(result.port).toBe(8080); - } - }); - - test("should reject non-integer PORT", () => { - const schema = createEnvSchema(); - const result = schema({ PORT: "not-a-number" }); - - expect(result).toBeInstanceOf(type.errors); - }); - }); - - describe("MIGRATIONS_PATH", () => { - test("should be undefined when not set", () => { - const schema = createEnvSchema(); - const result = schema({}); - - expect(result).not.toBeInstanceOf(type.errors); - if (!(result instanceof type.errors)) { - expect(result.migrationsPath).toBeUndefined(); - } - }); - - test("should accept a valid path", () => { - const schema = createEnvSchema(); - const result = schema({ MIGRATIONS_PATH: "/custom/migrations" }); - - expect(result).not.toBeInstanceOf(type.errors); - if (!(result instanceof type.errors)) { - expect(result.migrationsPath).toBe("/custom/migrations"); - } - }); - }); -}); diff --git a/app/server/core/config.ts b/app/server/core/config.ts index 01bcdbdf..a2f49a38 100644 --- a/app/server/core/config.ts +++ b/app/server/core/config.ts @@ -7,7 +7,7 @@ const envSchema = type({ SERVER_IDLE_TIMEOUT: 'string.integer.parse = "60"', RESTIC_HOSTNAME: "string = 'zerobyte'", PORT: 'string.integer.parse = "4096"', - "MIGRATIONS_PATH?": "string", + MIGRATIONS_PATH: "string?", }).pipe((s) => ({ __prod__: s.NODE_ENV === "production", environment: s.NODE_ENV,