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.

Added edge config npm modules

Steven Tey56381b514eea
diff --git a/lib/constants/default-redirects.ts b/lib/constants/default-redirects.ts
deleted file mode 100644
index 6c822695a6..0000000000
--- a/lib/constants/default-redirects.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-const DEFAULT_REDIRECTS = {
- home: "https://dub.sh",
- signin: "https://app.dub.sh/login",
- login: "https://app.dub.sh/login",
- register: "https://app.dub.sh/register",
- signup: "https://app.dub.sh/register",
- app: "https://app.dub.sh",
- dashboard: "https://app.dub.sh",
- links: "https://app.dub.sh/links",
- settings: "https://app.dub.sh/settings",
-};
-
-export default DEFAULT_REDIRECTS;
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index d6e3e3c210..b7667784fa 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -20,8 +20,39 @@ export const HOME_HOSTNAMES = new Set([
"localhost:3000",
]);
-export { default as RESERVED_KEYS } from "./reserved-keys";
-export { default as DEFAULT_REDIRECTS } from "./default-redirects";
+export const RESERVED_KEYS = new Set([
+ "api",
+ "va",
+ "static",
+ "stats",
+ "proxy",
+ "auth",
+ "pricing",
+ "about",
+ "placeholder",
+ "blog",
+ "careers",
+ "features",
+ "contact",
+ "terms",
+ "privacy",
+ "admin",
+ "help",
+ "new",
+ "info",
+ "demo",
+]);
+export const DEFAULT_REDIRECTS = {
+ home: "https://dub.sh",
+ signin: "https://app.dub.sh/login",
+ login: "https://app.dub.sh/login",
+ register: "https://app.dub.sh/register",
+ signup: "https://app.dub.sh/register",
+ app: "https://app.dub.sh",
+ dashboard: "https://app.dub.sh",
+ links: "https://app.dub.sh/links",
+ settings: "https://app.dub.sh/settings",
+};
export const FREE_PLAN_PROJECT_LIMIT = 5;
export const FAVICON_FOLDER = "/_static/favicons";
diff --git a/lib/constants/reserved-keys.ts b/lib/constants/reserved-keys.ts
deleted file mode 100644
index 084ea4c322..0000000000
--- a/lib/constants/reserved-keys.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-const RESERVED_KEYS = new Set([
- "api",
- "va",
- "static",
- "stats",
- "proxy",
- "auth",
- "pricing",
- "about",
- "placeholder",
- "blog",
- "careers",
- "features",
- "contact",
- "terms",
- "privacy",
- "admin",
- "help",
- "new",
- "info",
- "demo",
-]);
-
-export default RESERVED_KEYS;
diff --git a/lib/utils.ts b/lib/utils.ts
index 43a8559fd1..83c8fae4b3 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -6,6 +6,7 @@ import {
ccTLDs,
SECOND_LEVEL_DOMAINS,
} from "./constants";
+import { createClient } from "@vercel/edge-config";
export const nanoid = customAlphabet(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -320,24 +321,24 @@ export const log = async (message: string, type: "cron" | "links") => {
};
export const getBlackListedDomains = async () => {
- const res = await fetch(
+ const edgeConfig = createClient(
`https://edge-config.vercel.com/ecfg_2yhwl7yp0dcf60nn1cdid4a5xlsa?token=2482c0cb-1101-4e4b-8538-0f54cc43469e`,
);
- const data = await res.json();
- if (data?.items?.domains) {
- return new Set(data.items.domains);
+ const domains = await edgeConfig.get("domains");
+ if (domains) {
+ return new Set(domains);
} else {
return new Set();
}
};
export const getBlackListedEmails = async () => {
- const res = await fetch(
+ const edgeConfig = createClient(
`https://edge-config.vercel.com/ecfg_yugfr9n59gbwswp2lcdfbxrxfjir?token=5b797399-6c91-4f93-a75c-58d8d7cea3d1`,
);
- const data = await res.json();
- if (data?.items?.emails) {
- return new Set(data.items.emails);
+ const emails = await edgeConfig.get("emails");
+ if (emails) {
+ return new Set(emails);
} else {
return new Set();
}
diff --git a/package.json b/package.json
index 05260ce72c..b265884967 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"@upstash/ratelimit": "^0.1.5",
"@upstash/redis": "^1.12.0",
"@vercel/analytics": "^0.1.1",
+ "@vercel/edge-config": "^0.1.0-canary.14",
"@visx/axis": "^2.12.2",
"@visx/event": "^2.6.0",
"@visx/geo": "^2.10.0",
diff --git a/yarn.lock b/yarn.lock
index 085aef6ade..309379ccfa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1652,6 +1652,11 @@
resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-0.1.1.tgz#ce036282d76f03417141b54830930f915f40504b"
integrity sha512-34on7YtVt/yT8+QX7c5K2bcKYXnax06sQiK2PUdlQ1ABg5699mPdLGOSpS1gF//kR1s9oig4MCJ+N9nOjpaS6g==
+"@vercel/edge-config@^0.1.0-canary.14":
+ version "0.1.0-canary.14"
+ resolved "https://registry.yarnpkg.com/@vercel/edge-config/-/edge-config-0.1.0-canary.14.tgz#fcc14f6f6210c03731472b798432b9e27d140abb"
+ integrity sha512-i4QuCNBbdhKeFiPbrS5fdw5AEZqwHBRwrjcDwEw6eUNBq58idiu+QBly1VyCwO6GG/f4596Uoq8UQ8LLacaBtQ==
+
"@visx/axis@^2.12.2":
version "2.12.2"
resolved "https://registry.npmjs.org/@visx/axis/-/axis-2.12.2.tgz"