From 9950e50bfd4588ad7a6b6353dd1317295ee1d349 Mon Sep 17 00:00:00 2001 From: polaris Date: Sat, 29 Jun 2024 01:46:07 -0400 Subject: [PATCH] Changed leftovers to daphnis --- .gitignore | 6 +++++- .../forgot-password/emailforgotpassword.ts | 6 +++--- app/(sharing)/[token]/token.ts | 8 ++++---- auth/components/signin/action.ts | 4 ++-- auth/components/signup/action.ts | 14 ++++++++------ lib/api.ts | 2 +- tsconfig.json | 2 +- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index e37401f..30e0778 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,8 @@ logs .node_repl_history # Environment variables -.env* \ No newline at end of file +.env* + + +#nextjs +.next \ No newline at end of file diff --git a/app/(password-reset)/forgot-password/emailforgotpassword.ts b/app/(password-reset)/forgot-password/emailforgotpassword.ts index 3524ff8..49091f9 100644 --- a/app/(password-reset)/forgot-password/emailforgotpassword.ts +++ b/app/(password-reset)/forgot-password/emailforgotpassword.ts @@ -1,6 +1,6 @@ "use server"; -import { lachesis } from "@/lib/prisma"; +import { daphnis } from "@/lib/prisma"; import { randomUUID } from "crypto"; import { Resend } from "resend"; import { redirect } from "next/navigation"; @@ -39,7 +39,7 @@ export async function EmailPasswordResetLink(data: FormData) { }; } - const user = await lachesis.user.findUnique({ + const user = await daphnis.user.findUnique({ where: { email }, }); @@ -49,7 +49,7 @@ export async function EmailPasswordResetLink(data: FormData) { }; } - const token = await lachesis.passwordResetToken.create({ + const token = await daphnis.passwordResetToken.create({ data: { id: randomUUID(), userId: user.id, diff --git a/app/(sharing)/[token]/token.ts b/app/(sharing)/[token]/token.ts index 65f7d91..c64a064 100644 --- a/app/(sharing)/[token]/token.ts +++ b/app/(sharing)/[token]/token.ts @@ -1,7 +1,7 @@ "use server"; import { getAuth } from "@/auth/queries/getauth"; -import { lachesis } from "@/lib/prisma"; +import { daphnis } from "@/lib/prisma"; import { randomUUID } from "crypto"; import { randomBytes } from "crypto"; import { redirect } from "next/navigation"; @@ -20,7 +20,7 @@ export async function generateShareToken(id: number): Promise<{ } const gernatetoken = randomBytes(5).readUInt32BE(0).toString(); - const token = await lachesis.linkSharingToken.create({ + const token = await daphnis.linkSharingToken.create({ data: { playlogId: id, id: randomUUID(), @@ -34,7 +34,7 @@ export async function generateShareToken(id: number): Promise<{ } export async function shareScore(token: string) { - const PublicPage = await lachesis.linkSharingToken.findUnique({ + const PublicPage = await daphnis.linkSharingToken.findUnique({ where: { token, }, @@ -52,7 +52,7 @@ export async function shareScore(token: string) { const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds if (tokenAge > tokenAgeLimit) { - await lachesis.linkSharingToken.update({ + await daphnis.linkSharingToken.update({ where: { token, }, diff --git a/auth/components/signin/action.ts b/auth/components/signin/action.ts index ee1e1aa..acaf8a4 100644 --- a/auth/components/signin/action.ts +++ b/auth/components/signin/action.ts @@ -4,7 +4,7 @@ import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { Argon2id } from "oslo/password"; import { lucia } from "@/lib/lucia"; -import { lachesis } from "@/lib/prisma"; +import { daphnis } from "@/lib/prisma"; const signIn = async (formData: FormData) => { const formDataRaw = { @@ -13,7 +13,7 @@ const signIn = async (formData: FormData) => { }; try { - const user = await lachesis.user.findUnique({ + const user = await daphnis.user.findUnique({ where: { username: formDataRaw.username }, }); diff --git a/auth/components/signup/action.ts b/auth/components/signup/action.ts index d62b574..b990fc0 100644 --- a/auth/components/signup/action.ts +++ b/auth/components/signup/action.ts @@ -5,7 +5,7 @@ import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { Argon2id } from "oslo/password"; import { lucia } from "@/lib/lucia"; -import { lachesis, artemis } from "@/lib/prisma"; +import { daphnis, artemis } from "@/lib/prisma"; const signUp = async (formData: FormData) => { const formDataRaw = { @@ -22,7 +22,7 @@ const signUp = async (formData: FormData) => { try { // Check if access code is already used in lachesis database - const existingUser = await lachesis.user.findFirst({ + const existingUser = await daphnis.user.findFirst({ where: { accessCode: formDataRaw.accessCode, }, @@ -33,7 +33,7 @@ const signUp = async (formData: FormData) => { } // Check if username is already used in lachesis database - const existingUsername = await lachesis.user.findFirst({ + const existingUsername = await daphnis.user.findFirst({ where: { username: formDataRaw.username, }, @@ -43,7 +43,7 @@ const signUp = async (formData: FormData) => { return { error: "Username is currently taken" }; } - const existingEmail = await lachesis.user.findFirst({ + const existingEmail = await daphnis.user.findFirst({ where: { email: formDataRaw.email, }, @@ -68,7 +68,7 @@ const signUp = async (formData: FormData) => { const userId = generateId(15); // Create user in the lachesis database - await lachesis.user.create({ + await daphnis.user.create({ data: { id: userId, username: formDataRaw.username, @@ -90,10 +90,12 @@ const signUp = async (formData: FormData) => { console.log("Account created"); // Redirect to home page - redirect("/home"); } catch (error: any) { return { error: "Account creation failed: " + error.message }; } + + redirect("/home"); + }; export { signUp }; diff --git a/lib/api.ts b/lib/api.ts index 47a86af..8b2febd 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -5,7 +5,7 @@ import { artemis } from "@/lib/prisma"; import { daphnis } from "@/lib/prisma"; export async function getSongsWithTitles(userId: number) { try { - // Fetch songs from ChuniScorePlaylog + const songs = await artemis.chuni_score_playlog.findMany({ where: { user: userId, diff --git a/tsconfig.json b/tsconfig.json index e7ff90f..5a1e9c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "bundler", + "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve",