| 1 | import { unstable_cache } from "next/cache"; |
| 2 | import { db, settings |
| 3 | import { env } |
| 4 | |
| 5 | export const INSTANCE_SETTINGS_TAG = |
| 6 | |
| 7 | const DEFAULTS = { |
| 8 | appName: env.APP_NAME |
| 9 | appNameFromEnv: !!env.APP_NAME |
| 10 | appUrl: env.APP_URL |
| 11 | appUrlFromEnv: !!env.APP_URL |
| 12 | metaDescription: "", |
| 13 | registrationEnabled: true, |
| 14 | logoUrl: null as string |
| 15 | ogBannerUrl: null as string |
| 16 | socialProviders: [] as string |
| 17 | ogTitle: "", |
| 18 | ogDescription: "", |
| 19 | ogSiteName: "", |
| 20 | ogType: "website", |
| 21 | twitterCard: "summary_large_image", |
| 22 | twitterSite: "", |
| 23 | twitterCreator: "", |
| 24 | themeColor: "", |
| 25 | metaKeywords: "", |
| 26 | raw: {} as Record |
| 27 | }; |
| 28 | |
| 29 | export const getInstanceSettings = |
| 30 | async () => |
| 31 | try { |
| 32 | const rows = |
| 33 | const s = |
| 34 | return { |
| 35 | appName: env.APP_NAME |
| 36 | appNameFromEnv: !!env.APP_NAME |
| 37 | appUrl: env.APP_URL |
| 38 | appUrlFromEnv: !!env.APP_URL |
| 39 | metaDescription: s.meta_description |
| 40 | registrationEnabled: s.registration_enabled |
| 41 | logoUrl: s.logo_url |
| 42 | ogBannerUrl: s.og_banner_url |
| 43 | socialProviders: [ |
| 44 | ...(s.github_enabled |
| 45 | ...(s.discord_enabled |
| 46 | ], |
| 47 | ogTitle: s.og_title |
| 48 | ogDescription: s.og_description |
| 49 | ogSiteName: s.og_site_name |
| 50 | ogType: s.og_type |
| 51 | twitterCard: s.twitter_card |
| 52 | twitterSite: s.twitter_site |
| 53 | twitterCreator: s.twitter_creator |
| 54 | themeColor: s.theme_color |
| 55 | metaKeywords: s.meta_keywords |
| 56 | raw: s, |
| 57 | }; |
| 58 | } catch { |
| 59 | return DEFAULTS; |
| 60 | } |
| 61 | }, |
| 62 | [INSTANCE_SETTINGS_TAG], |
| 63 | { tags: [INSTANCE_SETTINGS_TAG |
| 64 | ); |