Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'main' into support-local-planetscale-wrapper

Steven Teya1732813f7f2
diff --cc apps/web/lib/planetscale.ts
index aec77de644,c31683d512..d45e1b2a08
--- a/apps/web/lib/planetscale.ts
+++ b/apps/web/lib/planetscale.ts
@@@ -30,8 -30,20 +30,20 @@@ export const getDomainViaEdge = async (
: null;
};
+ export const checkIfKeyExists = async (domain: string, key: string) => {
+ if (!process.env.DATABASE_URL) return null;
+
+ const { rows } =
+ (await conn.execute(
+ "SELECT 1 FROM Link WHERE domain = ? AND `key` = ? LIMIT 1",
+ [domain, decodeURIComponent(key)], // we need to make sure that the key is always decoded (cause that's how we store it in MySQL)
+ )) || {};
+
+ return rows && Array.isArray(rows) && rows.length > 0;
+ };
+
export const getLinkViaEdge = async (domain: string, key: string) => {
- if (!process.env.DATABASE_URL) return null;
+ if (!process.env.PLANET_SCALE_DATABASE_URL) return null;
const { rows } =
(await conn.execute(