Some checks failed
CI / Verify (push) Has been cancelled
API: lists, items and invitations modules (list, create, get, update, set-primary, items create/list, invitation create/accept/list-pending), BetterAuth session helper, list membership, mailer and Prisma schema plus migrations. Web: lists overview, list detail (items) and list management (settings) views, item and invitation forms/hooks, sign-up and invitation accept pages. Shared: shopping list DTOs. Tooling: ignore the generated TanStack Router cache (apps/web/.tanstack).
28 lines
809 B
TypeScript
28 lines
809 B
TypeScript
import { Hono } from 'hono'
|
|
|
|
import { requireSession } from '@/lib/auth-session'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { resultJson } from '@/lib/result-json'
|
|
import { validate } from '@/lib/validate'
|
|
import type { AppEnv } from '@/types'
|
|
|
|
import { CreateInvitationSchema } from './schema'
|
|
import { CreateInvitation } from './use-case'
|
|
|
|
/** POST /invitations — invites an email address to a list. */
|
|
export const createInvitationRoute = new Hono<AppEnv>().post(
|
|
'/',
|
|
requireSession,
|
|
validate.json(CreateInvitationSchema),
|
|
async (c) => {
|
|
const body = c.req.valid('json')
|
|
const result = await new CreateInvitation(prisma).execute({
|
|
listId: body.listId,
|
|
email: body.email,
|
|
invitedById: c.get('user').id,
|
|
})
|
|
|
|
return resultJson(c, result, { status: 201 })
|
|
},
|
|
)
|