Repository: cloudflare/wildebeest
File: frontend/src/routes/(frontend)/about/index.tsx (TypeScript)

Code before:
import { handleRequestGet as rulesHandleRequestGet } from 'wildebeest/functions/api/v1/instance/rules'
import { Accordion } from '~/components/Accordion/Accordion'
// import { AccountCard } from '~/components/AccountCard/AccountCard'
import { HtmlContent } from '~/components/HtmlContent/HtmlContent'
import { ServerSettingsData } from '~/routes/(admin)/settings/server-settings/layout'
import { Account } from '~/types'
import { getDocumentHead } from '~/utils/getDocumentHead'
import { instanceLoader } from '../layout'
import { getAdmins } from 'wildebeest/functions/api/wb/settings/server/admins'
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
import { AccountCard } from '~/components/AccountCard/AccountCard'
import { getNotFoundHtml } from '~/utils/getNotFoundHtml/getNotFoundHtml'

type AboutInfo = {
	image: string
	domain: string
	admin: { account: Account | null; email: string }
	rules: { id: number; text: string }[]
	extended_description: {
		content: string
	}
}

export const aboutInfoLoader = loader$<Promise<AboutInfo>>(async ({ resolveValue, request, platform, html }) => {
	throw html(404, getNotFoundHtml())

	// TODO: fetching the instance for the thumbnail, but that should be part of the settings
	const instance = await resolveValue(instanceLoader)

	const database = await getDatabase(platform)

	const brandingDataResp = await settingsHandleRequestGet(database)
	let brandingData: ServerSettingsData | null
	try {
		brandingData = await brandingDataResp.json()
	} catch {
		brandingData = null
	}

	const rulesResp = await rulesHandleRequestGet(database)
	let rules: { id: number; text: string }[] = []
	try {
		rules = await rulesResp.json()
	} catch {
		rules = []
	}

	const admins = await getAdmins(database)
	let adminAccount: Account | null = null


Review comment (suggestion):
here and for the settings page I thought of having an env and based on that 404ing or not

but I figured that it'd be a bit overengineered and not really that needed/useful (we can check social.eng first before synching cloudflare.social)

(also AFAIK we don't even provide a way to access those pages besides directly going to them via their url, so people probably won't try to access them)

Code after:
import { handleRequestGet as rulesHandleRequestGet } from 'wildebeest/functions/api/v1/instance/rules'
import { Accordion } from '~/components/Accordion/Accordion'
import { HtmlContent } from '~/components/HtmlContent/HtmlContent'
import { ServerSettingsData } from '~/routes/(admin)/settings/server-settings/layout'
import { Account } from '~/types'
import { getDocumentHead } from '~/utils/getDocumentHead'
import { instanceLoader } from '../layout'
import { getAdmins } from 'wildebeest/functions/api/wb/settings/server/admins'
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
import { AccountCard } from '~/components/AccountCard/AccountCard'

type AboutInfo = {
	image: string
	domain: string
	admin: { account: Account | null; email: string }
	rules: { id: number; text: string }[]
	extended_description: {
		content: string
	}
}

export const aboutInfoLoader = loader$<Promise<AboutInfo>>(async ({ resolveValue, request, platform }) => {
	// TODO: fetching the instance for the thumbnail, but that should be part of the settings
	const instance = await resolveValue(instanceLoader)

	const database = await getDatabase(platform)

	const brandingDataResp = await settingsHandleRequestGet(database)
	let brandingData: ServerSettingsData | null
	try {
		brandingData = await brandingDataResp.json()
	} catch {
		brandingData = null
	}

	const rulesResp = await rulesHandleRequestGet(database)
	let rules: { id: number; text: string }[] = []
	try {
		rules = await rulesResp.json()
	} catch {
		rules = []
	}

	const admins = await getAdmins(database)
	let adminAccount: Account | null = null

	const adminPerson = admins.find((admin) => admin[emailSymbol] === platform.ADMIN_EMAIL)

	if (adminPerson) {
		try {