mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 09:19:37 +02:00
Added auth!
This commit is contained in:
parent
3fd6d021f7
commit
372db59211
18 changed files with 1887 additions and 20 deletions
|
@ -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 });
|
||||
|
|
|
@ -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(),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue