dock config to postgres, auto-add /email on google oauth, improved email empty state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 17:42:27 +00:00
co-authored by Claude Opus 4.6
parent 466dc3adda
commit 7f04ecd644
7 changed files with 214 additions and 93 deletions
+9 -26
View File
@@ -1,36 +1,19 @@
import { mkdir } from 'node:fs/promises';
import { dirname } from 'node:path';
import { createRouter } from '../../create-router';
import { getUserDockFile } from '@@/data-path';
const ensureDir = (filePath: string) => mkdir(dirname(filePath), { recursive: true });
import { getDockPaths, setDockPaths } from 'officerdb';
export const dockRouter = createRouter();
// GET / — return dock.json, or null if it doesn't exist (frontend uses defaults)
// GET / — return dock paths, or null if none saved (frontend uses defaults)
dockRouter.get('/', async (ctx) => {
const email = ctx.get('user').email;
const filePath = getUserDockFile(email);
const file = Bun.file(filePath);
if (await file.exists()) {
try {
return ctx.json(await file.json());
} catch {
// corrupted file — treat as missing
}
}
return ctx.json(null);
const userId = ctx.get('user').id;
const paths = await getDockPaths(userId);
return ctx.json(paths);
});
// PUT / — full replacement of dock paths array
dockRouter.put('/', async (ctx) => {
const email = ctx.get('user').email;
const body = ctx.get('body');
const filePath = getUserDockFile(email);
await ensureDir(filePath);
await Bun.write(filePath, JSON.stringify(body, null, 2));
return ctx.json(body);
const userId = ctx.get('user').id;
const paths = ctx.get('body') as string[];
await setDockPaths(userId, paths);
return ctx.json(paths);
});