mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 13:17:37 +01:00
Self-hosted on Hetzner is the only reality now; the leftover references were
stale at best and a security hole at worst. Thorough sweep across code, config,
scripts, docs, and comments (84+ files). Self-hosted supabase.orangecat.ch is
kept; historical migration records stay accurate.
Functional / security fixes:
- cron-auth: prod detection was process.env.VERCEL (unset on the box!), so the
fail-closed 'CRON_SECRET unset -> 503' gate never fired in production. Now
keys on NODE_ENV=production. (security)
- auth trustHost: dropped the dead process.env.VERCEL===1 branch.
- AppFooter: read the baked-in build SHA instead of VERCEL_GIT_COMMIT_SHA/ENV.
- project bootstrap: removed 'neon projects create' + the Vercel deploy brief;
DB option is now self-hosted Postgres, deploy guidance is the self-hosted flow.
- db-url: removed the legacy NEON_DATABASE_URL* fallbacks (+ updated its test).
Infra / removals:
- deleted .github/workflows/vercel-deploy.yml and scripts/db/dump-from-{neon,supabase}.sh.
- stripped NEON_* env fallbacks from db dump/restore/sync scripts.
User-facing:
- desktop offline overlay no longer blames a 'Vercel hiccup'; privacy page +
PRIVACY_POLICY subprocessors now say Hetzner self-hosted / self-hosted Postgres.
Plus ~50 comment/doc rewrites (Vercel -> the cloud host/the box; Neon -> Postgres).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
/**
|
|
* Inline self-tests for db-url resolution.
|
|
* Run: npm run test:db-url
|
|
*/
|
|
import { getDatabaseDirectUrl, getDatabasePoolUrl } from "@/lib/db-url";
|
|
|
|
function assert(condition: boolean, message: string): void {
|
|
if (!condition) throw new Error(message);
|
|
}
|
|
|
|
function withEnv(
|
|
vars: Record<string, string | undefined>,
|
|
fn: () => void,
|
|
): void {
|
|
const prior = new Map<string, string | undefined>();
|
|
for (const key of Object.keys(vars)) {
|
|
prior.set(key, process.env[key]);
|
|
const value = vars[key];
|
|
if (value === undefined) delete process.env[key];
|
|
else process.env[key] = value;
|
|
}
|
|
try {
|
|
fn();
|
|
} finally {
|
|
for (const [key, value] of prior) {
|
|
if (value === undefined) delete process.env[key];
|
|
else process.env[key] = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
function runTests(): void {
|
|
let passed = 0;
|
|
const check = (label: string, fn: () => void) => {
|
|
fn();
|
|
passed += 1;
|
|
console.log(` ✓ ${label}`);
|
|
};
|
|
|
|
check("pool prefers DATABASE_POOL_URL", () => {
|
|
withEnv(
|
|
{
|
|
DATABASE_POOL_URL: "postgres://pool",
|
|
DATABASE_URL: "postgres://direct",
|
|
},
|
|
() => assert(getDatabasePoolUrl() === "postgres://pool", "expected pool"),
|
|
);
|
|
});
|
|
|
|
check("pool falls back to DATABASE_URL for local dev", () => {
|
|
withEnv(
|
|
{
|
|
DATABASE_POOL_URL: undefined,
|
|
DATABASE_URL: "postgres://local",
|
|
},
|
|
() => assert(getDatabasePoolUrl() === "postgres://local", "expected local"),
|
|
);
|
|
});
|
|
|
|
check("direct prefers DATABASE_URL", () => {
|
|
withEnv(
|
|
{
|
|
DATABASE_URL: "postgres://direct",
|
|
},
|
|
() => assert(getDatabaseDirectUrl() === "postgres://direct", "expected direct"),
|
|
);
|
|
});
|
|
|
|
check("direct does not fall back to pool URL", () => {
|
|
withEnv(
|
|
{
|
|
DATABASE_URL: undefined,
|
|
DATABASE_POOL_URL: "postgres://pool-only",
|
|
},
|
|
() => assert(getDatabaseDirectUrl() === undefined, "direct must stay undefined"),
|
|
);
|
|
});
|
|
|
|
console.log(`\n${passed} passed`);
|
|
}
|
|
|
|
runTests();
|