shellphone.app/app/customers/queries/get-current-customer.ts

22 lines
452 B
TypeScript
Raw Normal View History

2021-08-03 12:02:01 +00:00
import { resolver } from "blitz";
2021-07-31 14:33:18 +00:00
import db from "../../../db";
2021-07-31 14:33:18 +00:00
2021-08-03 12:02:01 +00:00
export default resolver.pipe(resolver.authorize(), async (_ = null, { session }) => {
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-08-03 12:02:01 +00:00
});