diff --git a/apps/web/src/actions/admin/modify-nav-item.ts b/apps/web/src/actions/admin/modify-nav-item.ts index a560dec7..2b6b05ad 100644 --- a/apps/web/src/actions/admin/modify-nav-item.ts +++ b/apps/web/src/actions/admin/modify-nav-item.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { adminAction } from "@/lib/safe-action"; -import { sadd, hset, removeNavItem } from "@/lib/utils/server/redis"; +import { redisSAdd, redisHSet, removeNavItem } from "@/lib/utils/server/redis"; import { revalidatePath } from "next/cache"; const metadataSchema = z.object({ @@ -16,8 +16,8 @@ const navAdminPage = "/admin/toggles/landing"; export const setItem = adminAction .schema(metadataSchema) .action(async ({ parsedInput: { name, url }, ctx: { user, userId } }) => { - await sadd("config:navitemslist", encodeURIComponent(name)); - await hset(`config:navitems:${encodeURIComponent(name)}`, { + await redisSAdd("config:navitemslist", encodeURIComponent(name)); + await redisHSet(`config:navitems:${encodeURIComponent(name)}`, { url, name, enabled: true, @@ -42,7 +42,7 @@ export const toggleItem = adminAction parsedInput: { name, statusToSet }, ctx: { user, userId }, }) => { - await hset(`config:navitems:${encodeURIComponent(name)}`, { + await redisHSet(`config:navitems:${encodeURIComponent(name)}`, { enabled: statusToSet, }); revalidatePath(navAdminPage); diff --git a/apps/web/src/actions/admin/registration-actions.ts b/apps/web/src/actions/admin/registration-actions.ts index 6c1b3fbb..1d069199 100644 --- a/apps/web/src/actions/admin/registration-actions.ts +++ b/apps/web/src/actions/admin/registration-actions.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { adminAction } from "@/lib/safe-action"; -import { set } from "@/lib/utils/server/redis"; +import { redisSet } from "@/lib/utils/server/redis"; import { revalidatePath } from "next/cache"; const defaultRegistrationToggleSchema = z.object({ @@ -16,7 +16,7 @@ const defaultRSVPLimitSchema = z.object({ export const toggleRegistrationEnabled = adminAction .schema(defaultRegistrationToggleSchema) .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { - await set("config:registration:registrationEnabled", enabled); + await redisSet("config:registration:registrationEnabled", enabled); revalidatePath("/admin/toggles/registration"); return { success: true, statusSet: enabled }; }); @@ -24,7 +24,10 @@ export const toggleRegistrationEnabled = adminAction export const toggleRegistrationMessageEnabled = adminAction .schema(defaultRegistrationToggleSchema) .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { - await set("config:registration:registrationMessageEnabled", enabled); + await redisSet( + "config:registration:registrationMessageEnabled", + enabled, + ); revalidatePath("/admin/toggles/registration"); return { success: true, statusSet: enabled }; }); @@ -32,7 +35,10 @@ export const toggleRegistrationMessageEnabled = adminAction export const toggleSecretRegistrationEnabled = adminAction .schema(defaultRegistrationToggleSchema) .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { - await set("config:registration:secretRegistrationEnabled", enabled); + await redisSet( + "config:registration:secretRegistrationEnabled", + enabled, + ); revalidatePath("/admin/toggles/registration"); return { success: true, statusSet: enabled }; }); @@ -40,7 +46,7 @@ export const toggleSecretRegistrationEnabled = adminAction export const toggleRSVPs = adminAction .schema(defaultRegistrationToggleSchema) .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { - await set("config:registration:allowRSVPs", enabled); + await redisSet("config:registration:allowRSVPs", enabled); revalidatePath("/admin/toggles/registration"); return { success: true, statusSet: enabled }; }); @@ -48,7 +54,7 @@ export const toggleRSVPs = adminAction export const setRSVPLimit = adminAction .schema(defaultRSVPLimitSchema) .action(async ({ parsedInput: { rsvpLimit }, ctx: { user, userId } }) => { - await set("config:registration:maxRSVPs", rsvpLimit); + await redisSet("config:registration:maxRSVPs", rsvpLimit); revalidatePath("/admin/toggles/registration"); return { success: true, statusSet: rsvpLimit }; }); diff --git a/apps/web/src/app/admin/toggles/registration/page.tsx b/apps/web/src/app/admin/toggles/registration/page.tsx index 40edb8cd..841fe64d 100644 --- a/apps/web/src/app/admin/toggles/registration/page.tsx +++ b/apps/web/src/app/admin/toggles/registration/page.tsx @@ -1,5 +1,5 @@ import { RegistrationToggles } from "@/components/admin/toggles/RegistrationSettings"; -import { mget } from "@/lib/utils/server/redis"; +import { redisMGet } from "@/lib/utils/server/redis"; import { parseRedisBoolean, parseRedisNumber } from "@/lib/utils/server/redis"; import c from "config"; @@ -9,7 +9,7 @@ export default async function Page() { defaultSecretRegistrationEnabled, defaultRSVPsEnabled, defaultRSVPLimit, - ]: (string | null)[] = await mget( + ]: (string | null)[] = await redisMGet( "config:registration:registrationEnabled", "config:registration:secretRegistrationEnabled", "config:registration:allowRSVPs", diff --git a/apps/web/src/app/register/page.tsx b/apps/web/src/app/register/page.tsx index 5ea9210b..26a24250 100644 --- a/apps/web/src/app/register/page.tsx +++ b/apps/web/src/app/register/page.tsx @@ -4,7 +4,7 @@ import { auth, currentUser } from "@clerk/nextjs"; import { redirect } from "next/navigation"; import Navbar from "@/components/shared/Navbar"; import Link from "next/link"; -import { mget } from "@/lib/utils/server/redis"; +import { redisMGet } from "@/lib/utils/server/redis"; import { parseRedisBoolean } from "@/lib/utils/server/redis"; import { Button } from "@/components/shadcn/ui/button"; import { getUser } from "db/functions"; @@ -22,7 +22,7 @@ export default async function Page() { const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: ( | string | null - )[] = await mget( + )[] = await redisMGet( "config:registration:registrationEnabled", "config:registration:secretRegistrationEnabled", ); diff --git a/apps/web/src/app/rsvp/page.tsx b/apps/web/src/app/rsvp/page.tsx index b55a66e8..841f315c 100644 --- a/apps/web/src/app/rsvp/page.tsx +++ b/apps/web/src/app/rsvp/page.tsx @@ -10,7 +10,7 @@ import { SignedOut, RedirectToSignIn } from "@clerk/nextjs"; import { parseRedisBoolean, parseRedisNumber, - get, + redisGet, } from "@/lib/utils/server/redis"; import Link from "next/link"; import { Button } from "@/components/shadcn/ui/button"; @@ -44,7 +44,7 @@ export default async function RsvpPage({ } const rsvpEnabled = parseRedisBoolean( - (await get("config:registration:allowRSVPs")) as + (await redisGet("config:registration:allowRSVPs")) as | string | boolean | null @@ -56,7 +56,7 @@ export default async function RsvpPage({ if (rsvpEnabled === true) { const rsvpLimit = parseRedisNumber( - await get("config:registration:maxRSVPs"), + await redisGet("config:registration:maxRSVPs"), c.rsvpDefaultLimit, ); diff --git a/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx b/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx index 20111d04..49244c2e 100644 --- a/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx +++ b/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx @@ -1,5 +1,5 @@ import { SignUp } from "@clerk/nextjs"; -import { mget } from "@/lib/utils/server/redis"; +import { redisMGet } from "@/lib/utils/server/redis"; import { parseRedisBoolean } from "@/lib/utils/server/redis"; import c from "config"; import { Button } from "@/components/shadcn/ui/button"; @@ -9,7 +9,7 @@ export default async function Page() { const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: ( | string | null - )[] = await mget( + )[] = await redisMGet( "config:registration:registrationEnabled", "config:registration:secretRegistrationEnabled", ); diff --git a/apps/web/src/lib/utils/server/redis.ts b/apps/web/src/lib/utils/server/redis.ts index 4fe8d40e..90b8d6ba 100644 --- a/apps/web/src/lib/utils/server/redis.ts +++ b/apps/web/src/lib/utils/server/redis.ts @@ -5,29 +5,29 @@ export function includeEnvPrefix(key: string) { return `${process.env.HK_ENV}_${key}`; } -export async function sadd(key: string, value: string): Promise { +export async function redisSAdd(key: string, value: string): Promise { return kv.sadd(includeEnvPrefix(key), value); } -export async function hset( +export async function redisHSet( key: string, value: Record, ): Promise { return kv.hset(includeEnvPrefix(key), value); } -export async function set( +export async function redisSet( key: string, value: TData, ): Promise { return kv.set(includeEnvPrefix(key), value); } -export async function get(key: string): Promise { +export async function redisGet(key: string): Promise { return kv.get(includeEnvPrefix(key)); } -export async function mget(...keys: string[]): Promise { +export async function redisMGet(...keys: string[]): Promise { return kv.mget(keys.map(includeEnvPrefix)); }