2021-07-31 15:57:43 +00:00
|
|
|
import { Ctx } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
import db from "../../../db";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default async function getCurrentCustomer(_ = null, { session }: Ctx) {
|
2021-07-31 15:57:43 +00:00
|
|
|
if (!session.userId) return null;
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
return db.customer.findFirst({
|
|
|
|
where: { id: session.userId },
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
encryptionKey: true,
|
|
|
|
accountSid: true,
|
|
|
|
authToken: true,
|
|
|
|
twimlAppSid: true,
|
|
|
|
paddleCustomerId: true,
|
|
|
|
paddleSubscriptionId: true,
|
|
|
|
user: true,
|
|
|
|
},
|
2021-07-31 15:57:43 +00:00
|
|
|
});
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|