feat: add basic webui

This commit is contained in:
2024-12-30 06:39:09 +08:00
parent 608a7fb9c6
commit a4c549e7c3
462 changed files with 35900 additions and 2491 deletions

41
packages/auth/server.ts Normal file
View File

@@ -0,0 +1,41 @@
import type { ReadonlyHeaders } from 'next/dist/server/web/spec-extension/adapters/headers';
import { headers } from 'next/headers';
import { buildAuth } from './better-auth.config';
import { env } from '@konobangu/env';
import { pool } from '@konobangu/database';
export const auth = buildAuth({
pool,
baseURL: env.NEXT_PUBLIC_APP_URL,
});
export const getSessionFromHeaders = async () => {
const h = await headers();
const session = await auth.api.getSession({
headers: h,
});
return {
...session,
headers: h,
userId: session?.user?.id,
orgId: session?.session?.activeOrganizationId ?? undefined,
};
};
export const getFullOrganizationFromSession = async (session: {
orgId?: string;
headers: ReadonlyHeaders;
}) => {
const orgId = session?.orgId;
const fullOrganization = await auth.api.getFullOrganization({
headers: session.headers,
query: { organizationId: orgId ?? undefined },
});
return {
fullOrganization,
};
};