mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-03 05:45:04 +03:00
- 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
29 lines
797 B
TypeScript
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.
|
|
}
|
|
}
|