You've already forked obsidian-visualiser
Beginning campaign UI and WS to get player state.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { z } from 'zod/v4';
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { campaignMembersTable, campaignTable } from '~/db/schema';
|
||||
import { CampaignValidation } from '~/shared/campaign.util';
|
||||
import { cryptURI } from '~/shared/general.util';
|
||||
|
||||
export default defineEventHandler(async (e) => {
|
||||
const body = await readValidatedBody(e, CampaignValidation.extend({ id: z.unknown(), }).safeParse);
|
||||
@@ -26,8 +28,10 @@ export default defineEventHandler(async (e) => {
|
||||
name: body.data.name,
|
||||
description: body.data.description,
|
||||
owner: session.user!.id,
|
||||
joinby: body.data.joinby,
|
||||
link: '',
|
||||
}).returning({ id: campaignTable.id }).get().id;
|
||||
|
||||
tx.update(campaignTable).set({ link: cryptURI('campaign', id) }).where(eq(campaignTable.id, id)).run();
|
||||
|
||||
tx.insert(campaignMembersTable).values({ id, rights: 'dm', user: session.user!.id }).run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user