mirror of
https://github.com/temetro/temetro.git
synced 2026-08-20 23:22:18 +00:00
backend: per-user settings store (/api/settings) + enable account deletion
- user_settings table (userId PK -> user, jsonb preferences) + migration - GET/PUT /api/settings (requireAuth, user-scoped; zod-validated flat map) - Better Auth user.deleteUser enabled so users can delete their own account Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,3 +7,4 @@ export * from "./tasks.js";
|
||||
export * from "./activity.js";
|
||||
export * from "./messaging.js";
|
||||
export * from "./notifications.js";
|
||||
export * from "./settings.js";
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
|
||||
import { user } from "./auth.js";
|
||||
|
||||
// Per-user preferences (notification toggles, profile extras). One row per
|
||||
// user, keyed by the Better Auth user id; the payload is a flat JSONB map so
|
||||
// the frontend can add settings without a migration.
|
||||
export const userSettings = pgTable("user_settings", {
|
||||
userId: text("user_id")
|
||||
.primaryKey()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
preferences: jsonb("preferences")
|
||||
.$type<Record<string, boolean | string>>()
|
||||
.notNull()
|
||||
.default({}),
|
||||
updatedAt: timestamp("updated_at")
|
||||
.defaultNow()
|
||||
.$onUpdate(() => new Date())
|
||||
.notNull(),
|
||||
});
|
||||
Reference in New Issue
Block a user