fix: rename trpc route for get booking
This commit is contained in:
@@ -174,6 +174,6 @@ const confirmationNumberInput = z.object({
|
||||
lang: z.nativeEnum(Lang).optional(),
|
||||
})
|
||||
|
||||
export const bookingConfirmationInput = confirmationNumberInput
|
||||
export const getBookingInput = confirmationNumberInput
|
||||
|
||||
export const getBookingStatusInput = confirmationNumberInput
|
||||
|
||||
@@ -11,23 +11,17 @@ import {
|
||||
import { getHotel } from "../hotels/utils"
|
||||
import { encrypt } from "../utils/encryption"
|
||||
import {
|
||||
bookingConfirmationInput,
|
||||
createRefIdInput,
|
||||
getBookingInput,
|
||||
getBookingStatusInput,
|
||||
} from "./input"
|
||||
import { bookingConfirmationSchema, createBookingSchema } from "./output"
|
||||
import { getBookedHotelRoom } from "./utils"
|
||||
|
||||
const meter = metrics.getMeter("trpc.booking")
|
||||
const getBookingConfirmationCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation"
|
||||
)
|
||||
const getBookingConfirmationSuccessCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation-success"
|
||||
)
|
||||
const getBookingConfirmationFailCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation-fail"
|
||||
)
|
||||
const getBookingCounter = meter.createCounter("trpc.booking.get")
|
||||
const getBookingSuccessCounter = meter.createCounter("trpc.booking.get-success")
|
||||
const getBookingFailCounter = meter.createCounter("trpc.booking.get-fail")
|
||||
|
||||
const getBookingStatusCounter = meter.createCounter("trpc.booking.status")
|
||||
const getBookingStatusSuccessCounter = meter.createCounter(
|
||||
@@ -38,13 +32,13 @@ const getBookingStatusFailCounter = meter.createCounter(
|
||||
)
|
||||
|
||||
export const bookingQueryRouter = router({
|
||||
confirmation: safeProtectedServiceProcedure
|
||||
.input(bookingConfirmationInput)
|
||||
get: safeProtectedServiceProcedure
|
||||
.input(getBookingInput)
|
||||
.query(async function ({
|
||||
ctx,
|
||||
input: { confirmationNumber, lang: inputLang },
|
||||
}) {
|
||||
getBookingConfirmationCounter.add(1, { confirmationNumber })
|
||||
getBookingCounter.add(1, { confirmationNumber })
|
||||
|
||||
let lang = ctx.lang ?? inputLang
|
||||
|
||||
@@ -61,7 +55,7 @@ export const bookingQueryRouter = router({
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
const responseMessage = await apiResponse.text()
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
error_type: "http_error",
|
||||
error: responseMessage,
|
||||
@@ -90,7 +84,7 @@ export const bookingQueryRouter = router({
|
||||
const apiJson = await apiResponse.json()
|
||||
const booking = bookingConfirmationSchema.safeParse(apiJson)
|
||||
if (!booking.success) {
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
error_type: "validation_error",
|
||||
error: JSON.stringify(booking.error),
|
||||
@@ -115,7 +109,7 @@ export const bookingQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!hotelData) {
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
hotelId: booking.data.hotelId,
|
||||
error_type: "http_error",
|
||||
@@ -136,7 +130,7 @@ export const bookingQueryRouter = router({
|
||||
throw serverErrorByStatus(404)
|
||||
}
|
||||
|
||||
getBookingConfirmationSuccessCounter.add(1, { confirmationNumber })
|
||||
getBookingSuccessCounter.add(1, { confirmationNumber })
|
||||
console.info(
|
||||
"api.booking.confirmation success",
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user