Fixed docker deploments, moved files to _folders in dispatch app

This commit is contained in:
PxlLoewe
2025-05-27 17:34:44 -07:00
parent 5d5b2dc91f
commit 571ddfba85
60 changed files with 251 additions and 406 deletions

View File

@@ -1,6 +1,6 @@
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_COOKIE_PREFIX=HUB
NEXTAUTH_SECRET=var
AUTH_HUB_COOKIE_PREFIX=HUB
AUTH_HUB_SECRET=var
DATABASE_URL=postgresql://persistant-data:persistant-data-pw@localhost:5432/var
DISCORD_OAUTH_CLIENT_ID=
DISCORD_OAUTH_SECRET=

View File

@@ -1,12 +1,12 @@
FROM node:22-alpine AS base
ARG DATABASE_URL
ENV DATABASE_URL=${DATABASE_URL}
ENV PNPM_HOME="/usr/local/pnpm"
ENV PATH="${PNPM_HOME}:${PATH}"
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN echo "NEXT_PUBLIC_DISPATCH_SERVER_URL=${NEXT_PUBLIC_DISPATCH_SERVER_URL}"
RUN pnpm add -g turbo@^2.5
FROM base AS builder

View File

@@ -1,6 +1,6 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { signIn, useSession } from "next-auth/react";
import { signIn } from "next-auth/react";
import Link from "next/link";
import { redirect, useSearchParams } from "next/navigation";
import { useState } from "react";
@@ -72,12 +72,7 @@ export const Login = () => {
<path d="M2.5 3A1.5 1.5 0 0 0 1 4.5v.793c.026.009.051.02.076.032L7.674 8.51c.206.1.446.1.652 0l6.598-3.185A.755.755 0 0 1 15 5.293V4.5A1.5 1.5 0 0 0 13.5 3h-11Z" />
<path d="M15 6.954 8.978 9.86a2.25 2.25 0 0 1-1.956 0L1 6.954V11.5A1.5 1.5 0 0 0 2.5 13h11a1.5 1.5 0 0 0 1.5-1.5V6.954Z" />
</svg>
<input
type="text"
className="grow"
{...form.register("email")}
placeholder="Email"
/>
<input type="text" className="grow" {...form.register("email")} placeholder="Email" />
</label>
<p className="text-error">
{typeof form.formState.errors.email?.message === "string"
@@ -111,11 +106,7 @@ export const Login = () => {
</Link>
</span>
<div className="card-actions mt-6">
<Button
disabled={isLoading}
isLoading={isLoading}
className="btn btn-primary btn-block"
>
<Button disabled={isLoading} isLoading={isLoading} className="btn btn-primary btn-block">
Login
</Button>
</div>

View File

@@ -70,21 +70,14 @@ export const VerticalNav = () => {
export const HorizontalNav = () => (
<div className="navbar bg-base-200 shadow-md rounded-lg mb-4">
<div className="flex items-center">
<a className="btn btn-ghost normal-case text-xl">
Virtual Air Rescue - HUB
</a>
<a className="btn btn-ghost normal-case text-xl">Virtual Air Rescue - HUB</a>
<WarningAlert />
</div>
<div className="flex items-center ml-auto">
<ul className="flex space-x-2 px-1">
<li>
<Link
href={process.env.NEXT_PUBLIC_DISPATCH_URL || "#!"}
rel="noopener noreferrer"
>
<button className="btn btn-sm btn-outline btn-primary">
Zur Leitstelle
</button>
<Link href={process.env.NEXT_PUBLIC_DISPATCH_URL || "#!"} rel="noopener noreferrer">
<button className="btn btn-sm btn-outline btn-primary">Zur Leitstelle</button>
</Link>
</li>
<li>

View File

@@ -27,14 +27,14 @@ export const options: AuthOptions = {
},
}),
],
secret: process.env.NEXTAUTH_SECRET,
secret: process.env.AUTH_HUB_SECRET,
session: {
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60,
},
cookies: {
sessionToken: {
name: `${process.env.NEXTAUTH_COOKIE_PREFIX}-next-auth.session-token`, // Ändere den Namen für App 1
name: `${process.env.AUTH_HUB_COOKIE_PREFIX}-next-auth.session-token`, // Ändere den Namen für App 1
options: {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
@@ -42,7 +42,7 @@ export const options: AuthOptions = {
},
},
csrfToken: {
name: `${process.env.NEXTAUTH_COOKIE_PREFIX}-next-auth.csrf-token`,
name: `${process.env.AUTH_HUB_COOKIE_PREFIX}-next-auth.csrf-token`,
options: {
httpOnly: true,
secure: process.env.NODE_ENV === "production",

View File

@@ -60,7 +60,7 @@ export const POST = async (req: NextRequest) => {
{
...accessRequest.user,
},
process.env.NEXTAUTH_SECRET as string,
process.env.AUTH_HUB_SECRET as string,
{
expiresIn: "30d",
},

View File

@@ -11,7 +11,7 @@ export const GET = async (req: NextRequest) => {
if (!authHeader || !token) {
return NextResponse.json({ error: "Not logged in" }, { status: 401 });
}
const decoded = await verify(token, process.env.NEXTAUTH_SECRET as string);
const decoded = await verify(token, process.env.AUTH_HUB_SECRET as string);
if (typeof decoded === "string")
return NextResponse.json({ error: "Invalid token" }, { status: 401 });
@@ -22,8 +22,7 @@ export const GET = async (req: NextRequest) => {
},
});
if (!user)
return NextResponse.json({ error: "User not found" }, { status: 404 });
if (!user) return NextResponse.json({ error: "User not found" }, { status: 404 });
setTimeout(async () => {
const moodleUser = await getMoodleUserById(user.id);
await prisma.user.update({
@@ -49,10 +48,7 @@ export const GET = async (req: NextRequest) => {
},
});
participatingEvents.forEach(async (p) => {
await inscribeToMoodleCourse(
p.Event.finisherMoodleCourseId!,
moodleUser?.id,
);
await inscribeToMoodleCourse(p.Event.finisherMoodleCourseId!, moodleUser?.id);
});
}, 1000);

View File

@@ -13,7 +13,7 @@ const geistMono = Geist_Mono({
subsets: ["latin"],
});
export default async ({
const RootLayout = async ({
children,
}: Readonly<{
children: React.ReactNode;
@@ -23,12 +23,14 @@ export default async ({
return (
<html lang="en">
<NextAuthSessionProvider session={session}>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
{children}
</body>
</NextAuthSessionProvider>
</html>
);
};
RootLayout.displayName = "RootLayout";
export default RootLayout;