aboutsummaryrefslogtreecommitdiff
path: root/communities/174bg/174bg.net/src
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-24 12:58:49 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-24 12:58:49 +0100
commite2066f51523ecba0f1991edd0c2b94f8f4cd1820 (patch)
tree8aedfff6c5d321d612278b40002a8e8037105b08 /communities/174bg/174bg.net/src
parent7bcfcc53b2dcbfb6efc82524f7bd078b716fd27b (diff)
downloadunnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.gz
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.bz2
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.tar.xz
unnamed-group-e2066f51523ecba0f1991edd0c2b94f8f4cd1820.zip
shorten community subdirs
Diffstat (limited to 'communities/174bg/174bg.net/src')
-rw-r--r--communities/174bg/174bg.net/src/app/api/auth/[...all]/route.js4
-rw-r--r--communities/174bg/174bg.net/src/app/globals.css8
-rw-r--r--communities/174bg/174bg.net/src/app/layout.js31
-rw-r--r--communities/174bg/174bg.net/src/app/login/page.js51
-rw-r--r--communities/174bg/174bg.net/src/app/page.js17
-rw-r--r--communities/174bg/174bg.net/src/app/secure/discord-data/page.js24
-rw-r--r--communities/174bg/174bg.net/src/app/secure/page.js13
-rw-r--r--communities/174bg/174bg.net/src/auth.js23
-rw-r--r--communities/174bg/174bg.net/src/lib/auth-client.js6
-rw-r--r--communities/174bg/174bg.net/src/proxy.js30
10 files changed, 207 insertions, 0 deletions
diff --git a/communities/174bg/174bg.net/src/app/api/auth/[...all]/route.js b/communities/174bg/174bg.net/src/app/api/auth/[...all]/route.js
new file mode 100644
index 0000000..2aabedd
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/api/auth/[...all]/route.js
@@ -0,0 +1,4 @@
+import { auth } from "@/auth";
+import { toNextJsHandler } from "better-auth/next-js";
+
+export const { POST, GET } = toNextJsHandler(auth);
diff --git a/communities/174bg/174bg.net/src/app/globals.css b/communities/174bg/174bg.net/src/app/globals.css
new file mode 100644
index 0000000..fa3342d
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/globals.css
@@ -0,0 +1,8 @@
+@import "tailwindcss";
+
+@theme inline {
+ --color-background: var(--background);
+ --color-foreground: var(--foreground);
+ --font-sans: var(--font-inter);
+ --font-mono: var(--font-fira-code);
+}
diff --git a/communities/174bg/174bg.net/src/app/layout.js b/communities/174bg/174bg.net/src/app/layout.js
new file mode 100644
index 0000000..9fb4098
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/layout.js
@@ -0,0 +1,31 @@
+import { Inter, Fira_Code } from "next/font/google";
+import "./globals.css";
+
+const inter = Inter({
+ variable: "--font-inter",
+ subsets: ["latin"],
+});
+
+const firaCode = Fira_Code({
+ variable: "--font-fira-code",
+ subsets: ["latin"],
+});
+
+export const metadata = {
+ title: "174th Battle Group",
+ description: "Vengeance Within Reach",
+ icons: {
+ icon: "/favicon.png",
+ },
+};
+
+export default function RootLayout({ children }) {
+ return (
+ <html
+ lang="en"
+ className={`${inter.variable} ${firaCode.variable} h-full antialiased`}
+ >
+ <body className="min-h-full flex flex-col">{children}</body>
+ </html>
+ );
+}
diff --git a/communities/174bg/174bg.net/src/app/login/page.js b/communities/174bg/174bg.net/src/app/login/page.js
new file mode 100644
index 0000000..b2b1ea8
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/login/page.js
@@ -0,0 +1,51 @@
+"use client";
+
+import { Suspense, useEffect, useState } from "react";
+import { useSearchParams } from "next/navigation";
+import { authClient } from "@/lib/auth-client";
+
+function LoginRedirect() {
+ const searchParams = useSearchParams();
+ const callbackUrl = searchParams.get("callbackUrl") ?? "/secure";
+ const [error, setError] = useState(null);
+
+ const signIn = () => {
+ authClient.signIn
+ .social({
+ provider: "discord",
+ callbackURL: callbackUrl,
+ })
+ .then(({ error }) => {
+ if (error) setError(error.message ?? "Sign-in failed");
+ });
+ };
+
+ useEffect(() => {
+ signIn();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ if (error) {
+ return (
+ <div>
+ <p>Error: {error}</p>
+ <button onClick={signIn}>Retry</button>
+ </div>
+ );
+ }
+
+ return (
+ <div>
+ <p>Redirecting to Discord...</p>
+ <button onClick={signIn}>Click here if nothing happens</button>
+ </div>
+ );
+}
+
+export default function LoginPage() {
+ return (
+ <Suspense fallback={<p>Loading...</p>}>
+ <LoginRedirect />
+ </Suspense>
+ );
+}
diff --git a/communities/174bg/174bg.net/src/app/page.js b/communities/174bg/174bg.net/src/app/page.js
new file mode 100644
index 0000000..9aaf53a
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/page.js
@@ -0,0 +1,17 @@
+export default function Home() {
+ return (
+ <div className="flex flex-col m-2 gap-4">
+ <h1 className="text-3xl font-bold">The 174th Battle Group</h1>
+ <h2 className="text-xl font-semibold opacity-75">
+ "Vengeance Within Reach"
+ </h2>
+ <p className="max-w-[666px] text-justify">
+ The 174th Battle Group is a logistical support unit of the United Earth
+ Empire's military. It is responsible for providing logistical support to
+ the UEE's forces, including transportation, supply, and maintenance. The
+ 174th Battle Group is known for its efficiency and reliability, and it
+ has played a crucial role in many of the UEE's military campaigns.
+ </p>
+ </div>
+ );
+}
diff --git a/communities/174bg/174bg.net/src/app/secure/discord-data/page.js b/communities/174bg/174bg.net/src/app/secure/discord-data/page.js
new file mode 100644
index 0000000..b906569
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/secure/discord-data/page.js
@@ -0,0 +1,24 @@
+import { auth } from "@/auth";
+import { headers } from "next/headers";
+
+export default async function DiscordData() {
+ const session = await auth.api.getSession({ headers: await headers() });
+ const accounts = await auth.api.listUserAccounts({
+ headers: await headers(),
+ });
+ const discordAccount = accounts?.find((a) => a.provider === "discord");
+
+ return (
+ <main>
+ <h1>Discord Data</h1>
+ <p>The following data is stored about your Discord account:</p>
+ <pre>
+ {JSON.stringify(
+ { user: session?.user, account: discordAccount },
+ null,
+ 2,
+ )}
+ </pre>
+ </main>
+ );
+}
diff --git a/communities/174bg/174bg.net/src/app/secure/page.js b/communities/174bg/174bg.net/src/app/secure/page.js
new file mode 100644
index 0000000..27312b7
--- /dev/null
+++ b/communities/174bg/174bg.net/src/app/secure/page.js
@@ -0,0 +1,13 @@
+import { auth } from "@/auth";
+import { headers } from "next/headers";
+
+export default async function SecurePage() {
+ const session = await auth.api.getSession({ headers: await headers() });
+
+ return (
+ <main>
+ <h1>Secure Area</h1>
+ <p>Welcome, {session?.user?.name ?? session?.user?.email}!</p>
+ </main>
+ );
+}
diff --git a/communities/174bg/174bg.net/src/auth.js b/communities/174bg/174bg.net/src/auth.js
new file mode 100644
index 0000000..4fa8408
--- /dev/null
+++ b/communities/174bg/174bg.net/src/auth.js
@@ -0,0 +1,23 @@
+import { betterAuth } from "better-auth";
+import { Pool } from "pg";
+
+const postgresUser = process.env.POSTGRES_USER || "postgres";
+const postgresPassword = process.env.POSTGRES_PASSWORD || "postgres";
+const postgresHost = process.env.POSTGRES_HOST || "postgres";
+const postgresPort = process.env.POSTGRES_PORT || 5432;
+const postgresDatabase = process.env.POSTGRES_DB || "postgres";
+
+export const auth = betterAuth({
+ baseURL: process.env.BETTER_AUTH_URL,
+ secret: process.env.BETTER_AUTH_SECRET,
+ database: new Pool({
+ connectionString: `postgresql://${postgresUser}:${postgresPassword}@${postgresHost}:${postgresPort}/${postgresDatabase}`,
+ }),
+ socialProviders: {
+ discord: {
+ clientId: process.env.DISCORD_CLIENT_ID,
+ clientSecret: process.env.DISCORD_CLIENT_SECRET,
+ scope: ["identify", "email", "guilds", "guilds.join"],
+ },
+ },
+});
diff --git a/communities/174bg/174bg.net/src/lib/auth-client.js b/communities/174bg/174bg.net/src/lib/auth-client.js
new file mode 100644
index 0000000..fd0a091
--- /dev/null
+++ b/communities/174bg/174bg.net/src/lib/auth-client.js
@@ -0,0 +1,6 @@
+import { createAuthClient } from "better-auth/react";
+
+export const authClient = createAuthClient({
+ /** The base URL of the server (optional if you're using the same domain) */
+ baseURL: process.env.BETTER_AUTH_URL,
+});
diff --git a/communities/174bg/174bg.net/src/proxy.js b/communities/174bg/174bg.net/src/proxy.js
new file mode 100644
index 0000000..dc0fa42
--- /dev/null
+++ b/communities/174bg/174bg.net/src/proxy.js
@@ -0,0 +1,30 @@
+import { NextResponse } from "next/server";
+
+export async function proxy(request) {
+ let session = null;
+
+ try {
+ const internalUrl =
+ process.env.BETTER_AUTH_URL_INTERNAL || "http://localhost:3000";
+ const res = await fetch(new URL("/api/auth/get-session", internalUrl), {
+ headers: {
+ cookie: request.headers.get("cookie") ?? "",
+ },
+ });
+ session = await res.json();
+ } catch {
+ // If session check fails, treat as unauthenticated
+ }
+
+ if (!session?.user) {
+ const loginUrl = new URL("/login", request.url);
+ loginUrl.searchParams.set("callbackUrl", request.nextUrl.pathname);
+ return NextResponse.redirect(loginUrl);
+ }
+
+ return NextResponse.next();
+}
+
+export const config = {
+ matcher: ["/secure/:path*"],
+};