feat: implement user authentication and dashboard
Adds a complete user authentication system and a protected dashboard. - Implements JWT-based authentication using ElysiaJS. - Integrates Prisma for database access and user management. - Creates a login page and protected routes for the dashboard. - Adds a dashboard layout with pages for API key management. - Includes necessary UI components from Mantine.
This commit is contained in:
31
prisma/schema.prisma
Normal file
31
prisma/schema.prisma
Normal file
@@ -0,0 +1,31 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
password String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
ApiKey ApiKey[]
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
id String @id @default(cuid())
|
||||
User User? @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
name String
|
||||
key String @unique @db.Text
|
||||
description String?
|
||||
expiredAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
30
prisma/seed.ts
Normal file
30
prisma/seed.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { prisma } from "@/server/lib/prisma";
|
||||
|
||||
const user = [
|
||||
{
|
||||
name: "Bip",
|
||||
email: "bip@bip.com",
|
||||
password: "bip",
|
||||
}
|
||||
];
|
||||
|
||||
; (async () => {
|
||||
for (const u of user) {
|
||||
await prisma.user.upsert({
|
||||
where: { email: u.email },
|
||||
create: u,
|
||||
update: u,
|
||||
})
|
||||
|
||||
console.log(`✅ User ${u.email} seeded successfully`)
|
||||
}
|
||||
|
||||
|
||||
})().catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
}).finally(() => {
|
||||
console.log("✅ Seeding completed successfully ")
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user