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 OcrConfig = {
|
||||
@@ -10,8 +10,8 @@ type OcrConfig = {
|
||||
export async function readOcrConfig(): Promise<OcrConfig | undefined> {
|
||||
const config = await readResourceConfig('optical-character-recognition');
|
||||
if (config.url) return { url: config.url, model: config.model ?? '' };
|
||||
// Fallback to legacy settings.json
|
||||
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
|
||||
// Fallback to legacy DB settings
|
||||
const settings = await readServerSettings();
|
||||
return settings.ocr as OcrConfig | undefined;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ ocrRouter.get('/', async (ctx) => {
|
||||
|
||||
ocrRouter.put('/', async (ctx) => {
|
||||
const body = await ctx.req.json<OcrConfig>();
|
||||
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
|
||||
const settings = await readServerSettings();
|
||||
settings.ocr = body;
|
||||
await Bun.write(settingsPath, JSON.stringify(settings, null, 2));
|
||||
await writeServerSettings(settings);
|
||||
return ctx.json({ success: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user