* [FEAT] Use dub.customer to issue dual-sided incentives * update dub implementation * uncommit yarn.lock * Update yarn.lock * account for self-hosting * remove comments --------- Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
19 lines
374 B
TypeScript
19 lines
374 B
TypeScript
import { Dub } from "dub";
|
|
|
|
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;
|
|
};
|