about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/constants.ts24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 0a6956909..0a8c32cd6 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -10,6 +10,22 @@ export const MAX_GRAPHEME_LENGTH = 300
 // but increasing limit per user feedback
 export const MAX_ALT_TEXT = 1000
 
+export function IS_LOCAL_DEV(url: string) {
+  return url.includes('localhost')
+}
+
+export function IS_STAGING(url: string) {
+  return !IS_LOCAL_DEV(url) && !IS_PROD(url)
+}
+
+export function IS_PROD(url: string) {
+  // NOTE
+  // until open federation, "production" is defined as the main server
+  // this definition will not work once federation is enabled!
+  // -prf
+  return url.startsWith('https://bsky.social')
+}
+
 export const PROD_TEAM_HANDLES = [
   'jay.bsky.social',
   'pfrazee.com',
@@ -43,14 +59,14 @@ export async function DEFAULT_FEEDS(
   serviceUrl: string,
   resolveHandle: (name: string) => Promise<string>,
 ) {
-  if (serviceUrl.includes('localhost')) {
+  if (IS_LOCAL_DEV(serviceUrl)) {
     // local dev
     const aliceDid = await resolveHandle('alice.test')
     return {
       pinned: [`at://${aliceDid}/app.bsky.feed.generator/alice-favs`],
       saved: [`at://${aliceDid}/app.bsky.feed.generator/alice-favs`],
     }
-  } else if (serviceUrl.includes('staging')) {
+  } else if (IS_STAGING(serviceUrl)) {
     // staging
     return {
       pinned: [STAGING_DEFAULT_FEED('whats-hot')],
@@ -90,9 +106,9 @@ export const STAGING_LINK_META_PROXY =
 export const PROD_LINK_META_PROXY = 'https://cardyb.bsky.app/v1/extract?url='
 
 export function LINK_META_PROXY(serviceUrl: string) {
-  if (serviceUrl.includes('localhost')) {
+  if (IS_LOCAL_DEV(serviceUrl)) {
     return STAGING_LINK_META_PROXY
-  } else if (serviceUrl.includes('staging')) {
+  } else if (IS_STAGING(serviceUrl)) {
     return STAGING_LINK_META_PROXY
   } else {
     return PROD_LINK_META_PROXY