feat(auth): add Discord OAuth sign-in and user timezones

Add persistent user and session storage, protected profile requests, and React sign-in controls. Capture and preserve each user's timezone, and load development and production configuration before migrations and server startup.
This commit is contained in:
syntaxbullet
2026-09-04 08:29:48 +02:00
parent 29bf75760b
commit d3cbf2f7dc
22 changed files with 997 additions and 24 deletions

View File

@@ -1,2 +1,22 @@
// Define application tables here with drizzle-orm/sqlite-core.
export {};
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const users = sqliteTable("users", {
id: text("id").primaryKey(),
discordId: text("discord_id").notNull().unique(),
username: text("username").notNull(),
globalName: text("global_name"),
avatarHash: text("avatar_hash"),
timezone: text("timezone").notNull().default("UTC"),
createdAt: integer("created_at").notNull(),
updatedAt: integer("updated_at").notNull(),
});
export const sessions = sqliteTable("sessions", {
tokenHash: text("token_hash").primaryKey(),
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
createdAt: integer("created_at").notNull(),
expiresAt: integer("expires_at").notNull(),
}, table => [
index("sessions_user_id_idx").on(table.userId),
index("sessions_expires_at_idx").on(table.expiresAt),
]);