Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { CreatePublicBookingInput } from '@repo/api-contract'
|
||||
import {
|
||||
PublicBookingServiceError,
|
||||
createPublicBooking,
|
||||
} from '@/modules/public-booking/services/public-booking.service'
|
||||
import type { AppContext } from '@/types/hono'
|
||||
|
||||
type ComplexSlugParams = { complexSlug: string }
|
||||
|
||||
export async function createPublicBookingHandler(c: AppContext) {
|
||||
const { complexSlug } = c.req.valid('param' as never) as ComplexSlugParams
|
||||
const payload = c.req.valid('json' as never) as CreatePublicBookingInput
|
||||
|
||||
try {
|
||||
const booking = await createPublicBooking(complexSlug, payload)
|
||||
return c.json(booking, 201)
|
||||
} catch (error) {
|
||||
if (error instanceof PublicBookingServiceError) {
|
||||
return c.json({ message: error.message }, error.status)
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
PublicBookingServiceError,
|
||||
getPublicBookingConfirmation,
|
||||
} from '@/modules/public-booking/services/public-booking.service'
|
||||
import type { AppContext } from '@/types/hono'
|
||||
|
||||
type BookingCodeParams = {
|
||||
complexSlug: string
|
||||
bookingCode: string
|
||||
}
|
||||
|
||||
export async function getPublicBookingConfirmationHandler(c: AppContext) {
|
||||
const { complexSlug, bookingCode } = c.req.valid('param' as never) as BookingCodeParams
|
||||
|
||||
try {
|
||||
const booking = await getPublicBookingConfirmation(complexSlug, bookingCode)
|
||||
return c.json(booking)
|
||||
} catch (error) {
|
||||
if (error instanceof PublicBookingServiceError) {
|
||||
return c.json({ message: error.message }, error.status)
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { PublicAvailabilityQuery } from '@repo/api-contract'
|
||||
import {
|
||||
PublicBookingServiceError,
|
||||
listPublicAvailability,
|
||||
} from '@/modules/public-booking/services/public-booking.service'
|
||||
import type { AppContext } from '@/types/hono'
|
||||
|
||||
type ComplexSlugParams = { complexSlug: string }
|
||||
|
||||
export async function listPublicAvailabilityHandler(c: AppContext) {
|
||||
const { complexSlug } = c.req.valid('param' as never) as ComplexSlugParams
|
||||
const query = c.req.valid('query' as never) as PublicAvailabilityQuery
|
||||
|
||||
try {
|
||||
const availability = await listPublicAvailability(complexSlug, query)
|
||||
return c.json(availability)
|
||||
} catch (error) {
|
||||
if (error instanceof PublicBookingServiceError) {
|
||||
return c.json({ message: error.message }, error.status)
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user