mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
added Session table for cookie-based auth
This commit is contained in:
@@ -11,6 +11,8 @@ export type {
|
||||
ProjectInsert,
|
||||
ProjectRecord,
|
||||
ProjectResponse,
|
||||
SessionInsert,
|
||||
SessionRecord,
|
||||
UserInsert,
|
||||
UserRecord,
|
||||
} from "./schema";
|
||||
@@ -27,6 +29,9 @@ export {
|
||||
Project,
|
||||
ProjectInsertSchema,
|
||||
ProjectSelectSchema,
|
||||
Session,
|
||||
SessionInsertSchema,
|
||||
SessionSelectSchema,
|
||||
User,
|
||||
UserInsertSchema,
|
||||
UserSelectSchema,
|
||||
|
||||
@@ -45,6 +45,16 @@ export const Project = pgTable("Project", {
|
||||
.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(
|
||||
"Issue",
|
||||
{
|
||||
@@ -86,6 +96,9 @@ export const ProjectInsertSchema = createInsertSchema(Project);
|
||||
export const IssueSelectSchema = createSelectSchema(Issue);
|
||||
export const IssueInsertSchema = createInsertSchema(Issue);
|
||||
|
||||
export const SessionSelectSchema = createSelectSchema(Session);
|
||||
export const SessionInsertSchema = createInsertSchema(Session);
|
||||
|
||||
// Types
|
||||
export type UserRecord = z.infer<typeof UserSelectSchema>;
|
||||
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 IssueInsert = z.infer<typeof IssueInsertSchema>;
|
||||
|
||||
export type SessionRecord = z.infer<typeof SessionSelectSchema>;
|
||||
export type SessionInsert = z.infer<typeof SessionInsertSchema>;
|
||||
|
||||
// Responses
|
||||
|
||||
export type IssueResponse = {
|
||||
|
||||
Reference in New Issue
Block a user