1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-28 09:19:37 +02:00

Added auth!

This commit is contained in:
Sean Morley 2024-04-03 00:51:12 +00:00
parent 3fd6d021f7
commit 372db59211
18 changed files with 1887 additions and 20 deletions

View file

@ -1,8 +1,9 @@
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import dotenv from "dotenv";
import * as schema from "$lib/db/schema";
dotenv.config();
const { DATABASE_URL } = process.env;
const client = postgres(DATABASE_URL);
export const db = drizzle(client, {});
const client = postgres(DATABASE_URL || ""); // Pass DATABASE_URL as a string argument
export const db = drizzle(client, { schema });

View file

@ -1,4 +1,11 @@
import { pgTable, json, text, serial } from "drizzle-orm/pg-core";
import {
pgTable,
text,
timestamp,
json,
serial,
varchar,
} from "drizzle-orm/pg-core";
export const featuredAdventures = pgTable("featuredAdventures", {
id: serial("id").primaryKey(),
@ -10,3 +17,22 @@ export const sharedAdventures = pgTable("sharedAdventures", {
id: text("id").primaryKey(),
data: json("data").notNull(),
});
export const userTable = pgTable("user", {
id: text("id").primaryKey(),
username: text("username").notNull(),
hashed_password: varchar("hashed_password").notNull(),
});
// export type SelectUser = typeof userTable.$inferSelect;
export const sessionTable = pgTable("session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => userTable.id),
expiresAt: timestamp("expires_at", {
withTimezone: true,
mode: "date",
}).notNull(),
});