Files
OmniRoute/src/lib/db/secrets.ts
diegosouzapw 92e0f242c7 fix(build): resolve all TypeScript compilation errors and Next.js 15 dynamic route slug conflicts
- Fix Next.js 15 async params in 4 API route handlers (accounts, providers, registered-keys)
- Move providers/[id]/limits → providers/[provider]/limits to resolve slug name conflict
- Add keytar to serverExternalPackages and KNOWN_EXTERNALS in next.config.mjs
- Fix Zod z.record() arity across a2a.ts and issues/report/route.ts
- Fix SearchResponse interface (optional answer property) in SearchTools and ResultsPanel
- Fix ProviderLimits implicit any types in index.tsx and utils.tsx
- Fix better-sqlite3 prepare<T> generic usage in secrets.ts
- Remove duplicate pricing keys (gemini-3-flash-preview)
- Cast analytics result, ApiErrorType import, TaskRoutingConfig type
- Remove rogue app/ duplicate directory from project root

Resolves: #560
2026-03-23 18:23:08 -03:00

29 lines
797 B
TypeScript

import { getDbInstance } from "./core";
interface SecretRow {
value?: string;
}
export function getPersistedSecret(key: string): string | null {
try {
const db = getDbInstance();
const row = db
.prepare("SELECT value FROM key_value WHERE namespace = 'secrets' AND key = ?")
.get(key) as SecretRow | undefined;
return typeof row?.value === "string" ? JSON.parse(row.value) : null;
} catch {
return null;
}
}
export function persistSecret(key: string, value: string): void {
try {
const db = getDbInstance();
db.prepare(
"INSERT OR IGNORE INTO key_value (namespace, key, value) VALUES ('secrets', ?, ?)"
).run(key, JSON.stringify(value));
} catch {
// Non-fatal: secrets still work for the current process if persistence fails.
}
}