Install Prisma

This commit is contained in:
May 2024-07-09 21:54:17 -07:00
parent 3f9e8f7913
commit 348cb6c204
Signed by: split
GPG key ID: C325C61F0BF517C0
9 changed files with 1921 additions and 1802 deletions

View file

@ -11,4 +11,7 @@ OAUTH2__CLIENT_ID=
OAUTH2__CLIENT_SECRET=
# Userinfo route
USERINFO__ROUTE=
USERINFO__ROUTE=
# Prisma database URL
DATABASE_URL="file:./data.db"

2
.gitignore vendored
View file

@ -19,3 +19,5 @@ Thumbs.db
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
data.db*

BIN
bun.lockb

Binary file not shown.

3677
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,7 @@
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prisma": "^5.16.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
@ -25,6 +26,7 @@
},
"type": "module",
"dependencies": {
"@fontsource-variable/inter": "^5.0.18"
"@fontsource-variable/inter": "^5.0.18",
"@prisma/client": "5.16.2"
}
}

View file

@ -0,0 +1,9 @@
-- CreateTable
CREATE TABLE "Token" (
"id" TEXT NOT NULL PRIMARY KEY,
"token" TEXT NOT NULL,
"refreshToken" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "Token_id_key" ON "Token"("id");

View file

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"

17
prisma/schema.prisma Normal file
View file

@ -0,0 +1,17 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Token {
id String @id @unique @default(uuid())
token String
refreshToken String
}

View file

@ -1,8 +1,14 @@
import { error, redirect, type Cookies } from "@sveltejs/kit"
import configuration from "./configuration"
import type { User } from "./types"
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient()
// Map of OAuth2 states
const states = new Map<string, { redirect_uri: string, timeout: ReturnType<typeof setTimeout> }>()
// Cache of userinfo
const usercache = new Map<string, User>()
/**
* @description Launch an OAuth2 login request for this request.