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

View File

@@ -0,0 +1,31 @@
import 'server-only';
import { env } from '@konobangu/env';
import { Liveblocks as LiveblocksNode } from '@liveblocks/node';
type AuthenticateOptions = {
userId: string;
orgId: string;
userInfo: Liveblocks['UserMeta']['info'];
};
export const authenticate = async ({
userId,
orgId,
userInfo,
}: AuthenticateOptions) => {
const liveblocks = new LiveblocksNode({
secret: env.LIVEBLOCKS_SECRET,
});
// Start an auth session inside your endpoint
const session = liveblocks.prepareSession(userId, { userInfo });
// Use a naming pattern to allow access to rooms with wildcards
// Giving the user write access on their organization
session.allow(`${orgId}:*`, session.FULL_ACCESS);
// Authorize the user and return the result
const { status, body } = await session.authorize();
return new Response(body, { status });
};