added Session table for cookie-based auth

This commit is contained in:
Oliver Bryan
2026-01-09 05:31:13 +00:00
parent ad138059db
commit 7201646b0a
2 changed files with 21 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ export type {
ProjectInsert, ProjectInsert,
ProjectRecord, ProjectRecord,
ProjectResponse, ProjectResponse,
SessionInsert,
SessionRecord,
UserInsert, UserInsert,
UserRecord, UserRecord,
} from "./schema"; } from "./schema";
@@ -27,6 +29,9 @@ export {
Project, Project,
ProjectInsertSchema, ProjectInsertSchema,
ProjectSelectSchema, ProjectSelectSchema,
Session,
SessionInsertSchema,
SessionSelectSchema,
User, User,
UserInsertSchema, UserInsertSchema,
UserSelectSchema, UserSelectSchema,

View File

@@ -45,6 +45,16 @@ export const Project = pgTable("Project", {
.references(() => User.id), .references(() => User.id),
}); });
export const Session = pgTable("Session", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
userId: integer()
.notNull()
.references(() => User.id),
csrfToken: varchar({ length: 64 }).notNull(),
expiresAt: timestamp({ withTimezone: false }).notNull(),
createdAt: timestamp({ withTimezone: false }).defaultNow(),
});
export const Issue = pgTable( export const Issue = pgTable(
"Issue", "Issue",
{ {
@@ -86,6 +96,9 @@ export const ProjectInsertSchema = createInsertSchema(Project);
export const IssueSelectSchema = createSelectSchema(Issue); export const IssueSelectSchema = createSelectSchema(Issue);
export const IssueInsertSchema = createInsertSchema(Issue); export const IssueInsertSchema = createInsertSchema(Issue);
export const SessionSelectSchema = createSelectSchema(Session);
export const SessionInsertSchema = createInsertSchema(Session);
// Types // Types
export type UserRecord = z.infer<typeof UserSelectSchema>; export type UserRecord = z.infer<typeof UserSelectSchema>;
export type UserInsert = z.infer<typeof UserInsertSchema>; export type UserInsert = z.infer<typeof UserInsertSchema>;
@@ -102,6 +115,9 @@ export type ProjectInsert = z.infer<typeof ProjectInsertSchema>;
export type IssueRecord = z.infer<typeof IssueSelectSchema>; export type IssueRecord = z.infer<typeof IssueSelectSchema>;
export type IssueInsert = z.infer<typeof IssueInsertSchema>; export type IssueInsert = z.infer<typeof IssueInsertSchema>;
export type SessionRecord = z.infer<typeof SessionSelectSchema>;
export type SessionInsert = z.infer<typeof SessionInsertSchema>;
// Responses // Responses
export type IssueResponse = { export type IssueResponse = {