shellphone.app/app/phone-numbers/queries/get-customer-phone-number.ts

20 lines
485 B
TypeScript
Raw Normal View History

import { resolver } from "blitz";
import db from "db";
import { z } from "zod";
2021-07-31 14:33:18 +00:00
const GetCustomerPhoneNumber = z.object({
// This accepts type of undefined, but is required at runtime
customerId: z.string().optional().refine(Boolean, "Required"),
});
2021-07-31 14:33:18 +00:00
export default resolver.pipe(resolver.zod(GetCustomerPhoneNumber), async ({ customerId }) =>
db.phoneNumber.findFirst({
where: { customerId },
select: {
id: true,
phoneNumber: true,
phoneNumberSid: true,
},
})
);