Compare commits

..

No commits in common. "21910eca416d4a413c9e84795965edeffb202c22" and "dfef859ede0257b2002be1a1b51556aa9a18d0f5" have entirely different histories.

2 changed files with 38 additions and 42 deletions

View file

@ -18,8 +18,7 @@ const app = new Elysia()
.use(statsApp)
.use(partyApp)
.use(partyAnalysisApp)
.use(partySocketApp)
.get("/", () => ({ ok: true })),
.use(partySocketApp),
)
.listen(4000);

View file

@ -1,49 +1,46 @@
import { createServerFn } from "@tanstack/react-start";
export interface AuthSession {
user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
};
session: {
id: string;
createdAt: Date;
updatedAt: Date;
userId: string;
expiresAt: Date;
token: string;
ipAddress?: string | null | undefined;
userAgent?: string | null | undefined;
};
user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
};
session: {
id: string;
createdAt: Date;
updatedAt: Date;
userId: string;
expiresAt: Date;
token: string;
ipAddress?: string | null | undefined;
userAgent?: string | null | undefined;
};
}
export const getSession = createServerFn({ method: "GET" }).handler(
async (): Promise<AuthSession | null> => {
const { getRequestHeaders } = await import("@tanstack/react-start/server");
const headers = getRequestHeaders();
const resolvedBaseUrl =
process.env.VITE_BETTER_AUTH_URL ??
import.meta.env.VITE_BETTER_AUTH_URL ??
headers.get("origin") ??
"http://localhost:3000";
const response = await fetch(
new URL("/api/auth/get-session", resolvedBaseUrl),
{ headers },
).catch((e) => {
console.error(e);
return { ok: false } as const;
});
async (): Promise<AuthSession | null> => {
const { getRequestHeaders } = await import("@tanstack/react-start/server");
const headers = getRequestHeaders();
const resolvedBaseUrl =
process.env.VITE_BETTER_AUTH_URL ??
import.meta.env.VITE_BETTER_AUTH_URL ??
headers.get("origin") ??
"http://127.0.0.1:3000";
const response = await fetch(
new URL("/api/auth/get-session", resolvedBaseUrl),
{ headers },
);
if (!response.ok) {
return null;
}
if (!response.ok) {
return null;
}
const data = (await response.json()) as AuthSession | null;
return data ?? null;
},
const data = (await response.json()) as AuthSession | null;
return data ?? null;
},
);