Initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { CreateComplexInput } from '@repo/api-contract'
|
||||
import type { AppContext } from '@/types/hono'
|
||||
import { createComplex } from '@/modules/complex/services/complex.service'
|
||||
|
||||
export async function createComplexHandler(c: AppContext) {
|
||||
const payload = c.req.valid('json' as never) as CreateComplexInput
|
||||
|
||||
const authUser = c.get('authUser')
|
||||
const adminEmail = authUser.email
|
||||
|
||||
if (!adminEmail) {
|
||||
return c.json({ message: 'El usuario autenticado no tiene email.' }, 400)
|
||||
}
|
||||
|
||||
const complex = await createComplex({
|
||||
complexName: payload.complexName,
|
||||
physicalAddress: payload.physicalAddress,
|
||||
adminEmail,
|
||||
planCode: payload.planCode,
|
||||
})
|
||||
|
||||
return c.json(complex, 201)
|
||||
}
|
||||
Reference in New Issue
Block a user