feat: add collaborative shopping lists with items and invitations
Some checks failed
CI / Verify (push) Has been cancelled
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).
This commit is contained in:
27
apps/api/src/modules/invitations/create/route.ts
Normal file
27
apps/api/src/modules/invitations/create/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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 })
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user