chore(repo): prune dead code and duplicate abstractions (#3413)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-12 13:09:42 +02:00
1 parent c17091768c
commit c9fdf8fead
2937 files changed
+42233 -176793

No files matched your search

-1
View File
@@ -13,7 +13,6 @@
},
"devDependencies": {
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"typescript": "catalog:ts7",
"vitest": "catalog:",
"yaml": "catalog:"
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {generateKeyPairSync} from 'node:crypto';
import {mkdtempSync, rmSync, writeFileSync} from 'node:fs';
import {tmpdir} from 'node:os';
import {join} from 'node:path';
import {loadConfig, resetConfig} from '@fluxer/config/src/ConfigLoader';
import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest';
@@ -83,24 +80,6 @@ describe('ConfigLoader', () => {
expect((await loadConfig()).domain.base_domain).toBe('localhost');
});
test('loadConfig reads secrets from NAME_FILE', async () => {
const dir = mkdtempSync(join(tmpdir(), 'fluxer-config-file-'));
try {
const path = join(dir, 'postgres_password');
writeFileSync(path, 'from-secret-file\n');
stubMinimalEnv({FLUXER_POSTGRES_PASSWORD: '', FLUXER_POSTGRES_PASSWORD_FILE: path});
const config = await loadConfig();
expect(config.database.postgres.password).toBe('from-secret-file');
} finally {
rmSync(dir, {recursive: true, force: true});
}
});
test('loadConfig rejects NAME and NAME_FILE together', async () => {
stubMinimalEnv({FLUXER_SUDO_MODE_SECRET_FILE: '/run/secrets/sudo'});
await expect(loadConfig()).rejects.toThrow('FLUXER_SUDO_MODE_SECRET and FLUXER_SUDO_MODE_SECRET_FILE are both set');
});
test('endpoint overrides take precedence over derived endpoints', async () => {
stubMinimalEnv({
FLUXER_API_ENDPOINT: 'https://custom-api.example.com',
@@ -369,16 +348,6 @@ describe('ConfigLoader', () => {
await expect(loadConfig()).rejects.toThrow('FLUXER_POSTGRES_PORT');
});
test('rejects a non-integer port', async () => {
stubMinimalEnv({FLUXER_API_PORT: '80a'});
await expect(loadConfig()).rejects.toThrow('FLUXER_API_PORT must be an integer, got "80a"');
});
test('rejects malformed JSON for a JSON-shaped variable', async () => {
stubMinimalEnv({FLUXER_LIVEKIT_DEFAULT_REGION: '{bad'});
await expect(loadConfig()).rejects.toThrow('FLUXER_LIVEKIT_DEFAULT_REGION must be valid JSON');
});
test('rejects a non-boolean Postgres prepared statements value', async () => {
stubMinimalEnv({FLUXER_POSTGRES_PREPARED_STATEMENTS: 'maybe'});
await expect(loadConfig()).rejects.toThrow('FLUXER_POSTGRES_PREPARED_STATEMENTS');
@@ -107,23 +107,3 @@ describe('parsePublicOrigin', () => {
expect(parsePublicOrigin('https://user:[email protected]')).toBeNull();
});
});
describe('endpoints derived from a public origin', () => {
test('an origin with a non-standard port ports every derived endpoint', () => {
const origin = parsePublicOrigin('https://chat.example.com:29080');
assert.ok(origin);
const endpoints = deriveEndpointsFromDomain(origin);
expect(endpoints.api_client).toBe('https://chat.example.com:29080/api');
expect(endpoints.app).toBe('https://chat.example.com:29080');
expect(endpoints.gateway).toBe('wss://chat.example.com:29080/gateway');
expect(endpoints.admin).toBe('https://chat.example.com:29080/admin');
});
test('an origin written with an explicit :443 derives portless endpoints', () => {
const origin = parsePublicOrigin('https://chat.example.com:443');
assert.ok(origin);
const endpoints = deriveEndpointsFromDomain(origin);
expect(endpoints.admin).toBe('https://chat.example.com/admin');
expect(endpoints.app).toBe('https://chat.example.com');
expect(endpoints.gateway).toBe('wss://chat.example.com/gateway');
});
});
@@ -176,25 +176,6 @@ async function loadApiConfig(env: Record<string, string>): Promise<MasterConfig>
return loadConfig();
}
describe('Compose environment interpolation', () => {
test.each([
[`\${VALUE}`, {VALUE: 'set'}, 'set'],
['$VALUE/path', {VALUE: 'set'}, 'set/path'],
[`\${VALUE:-fallback}`, {VALUE: ''}, 'fallback'],
[`\${VALUE:-\${OTHER:-fallback}}`, {OTHER: 'nested'}, 'nested'],
[`\${VALUE:+alternate}`, {VALUE: 'set'}, 'alternate'],
[`\${VALUE:+alternate}`, {}, ''],
[`\${VALUE:?required}`, {VALUE: 'set'}, 'set'],
] as const)('expands %s with %j to %s', (source, environment, expected) => {
expect(expand(source, environment)).toBe(expected);
});
test('rejects a missing required value and unbalanced interpolation', () => {
expect(() => expand(`\${VALUE:?required}`, {})).toThrow('VALUE is required: required');
expect(() => expand('${VALUE:-fallback', {})).toThrow('unbalanced interpolation');
});
});
describe('the shipped compose stack expanded on a non-default port', () => {
test('every service handed a public URL is handed the base domain and port that repair it', () => {
const starved = serviceNames