shellphone.app/app/phone-numbers/queries/get-current-customer-phone-number.ts
m5r 2cf53533a3 replace early returns with NotFoundError
test /api/webhook/incoming-message
2021-08-02 21:44:04 +08:00

21 lines
502 B
TypeScript

import { NotFoundError, resolver } from "blitz";
import db from "db";
import getCurrentCustomer from "../../customers/queries/get-current-customer";
export default resolver.pipe(resolver.authorize(), async (_ = null, context) => {
const customer = await getCurrentCustomer(null, context);
if (!customer) {
throw new NotFoundError();
}
return db.phoneNumber.findFirst({
where: { customerId: customer.id },
select: {
id: true,
phoneNumber: true,
phoneNumberSid: true,
},
});
});