Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
19 lines
382 B
TypeScript
19 lines
382 B
TypeScript
import { Dub } from "dub-package";
|
|
|
|
export const dub = new Dub({
|
|
token: process.env.DUB_API_KEY,
|
|
});
|
|
|
|
export const getDubCustomer = async (userId: string) => {
|
|
if (!process.env.DUB_API_KEY) {
|
|
return null;
|
|
}
|
|
|
|
const customer = await dub.customers.list({
|
|
externalId: userId,
|
|
includeExpandedFields: true,
|
|
});
|
|
|
|
return customer.length > 0 ? customer[0] : null;
|
|
};
|