migration to postgres
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createRouter } from '../../create-router';
|
||||
import { settingsPath } from './server-settings';
|
||||
import { readServerSettings, writeServerSettings } from 'officerdb';
|
||||
import { readResourceConfig } from './resources';
|
||||
|
||||
type TtsConfig = {
|
||||
@@ -18,8 +18,8 @@ function maskSecret(value: string | undefined): string | undefined {
|
||||
export async function readTtsConfig(): Promise<TtsConfig | undefined> {
|
||||
const config = await readResourceConfig('text-to-speech');
|
||||
if (!config.url && !config.provider) {
|
||||
// Fallback to legacy settings.json
|
||||
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
|
||||
// Fallback to legacy DB settings
|
||||
const settings = await readServerSettings();
|
||||
return settings.tts as TtsConfig | undefined;
|
||||
}
|
||||
return {
|
||||
@@ -41,15 +41,15 @@ ttsRouter.get('/', async (ctx) => {
|
||||
|
||||
ttsRouter.put('/', async (ctx) => {
|
||||
const body = await ctx.req.json<TtsConfig>();
|
||||
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
|
||||
const settings = await readServerSettings();
|
||||
|
||||
const existing: TtsConfig | undefined = settings.tts;
|
||||
const existing: TtsConfig | undefined = settings.tts as TtsConfig | undefined;
|
||||
if (existing && body.apiKey?.includes('****')) {
|
||||
body.apiKey = existing.apiKey;
|
||||
}
|
||||
|
||||
settings.tts = body;
|
||||
await Bun.write(settingsPath, JSON.stringify(settings, null, 2));
|
||||
await writeServerSettings(settings);
|
||||
return ctx.json({ success: true });
|
||||
});
|
||||
|
||||
@@ -152,8 +152,8 @@ async function fetchHuggingFaceVoices(repoId: string): Promise<{ flat: string[];
|
||||
ttsRouter.post('/test', async (ctx) => {
|
||||
const body = await ctx.req.json<TtsConfig>();
|
||||
|
||||
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
|
||||
const saved: TtsConfig | undefined = settings.tts;
|
||||
const settings = await readServerSettings();
|
||||
const saved: TtsConfig | undefined = settings.tts as TtsConfig | undefined;
|
||||
if (saved && body.apiKey?.includes('****')) {
|
||||
body.apiKey = saved.apiKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user