@@ -5,6 +5,7 @@ import { getServerSession } from "next-auth";
55
66import { errorhandler } from "@/lib/errorHandler" ;
77import prisma from "@/lib/prisma" ;
8+ import { redis } from "@/lib/redis" ;
89import { CustomUser } from "@/lib/types" ;
910
1011import { authOptions } from "../../auth/[...nextauth]" ;
@@ -74,6 +75,11 @@ export default async function handle(
7475 } ,
7576 } ) ;
7677
78+ // Cache the logo URL in Redis if logo exists
79+ if ( logo ) {
80+ await redis . set ( `brand:logo:${ teamId } ` , logo ) ;
81+ }
82+
7783 return res . status ( 200 ) . json ( brand ) ;
7884 } else if ( req . method === "PUT" ) {
7985 // PUT /api/teams/:teamId/branding
@@ -94,6 +100,14 @@ export default async function handle(
94100 } ,
95101 } ) ;
96102
103+ // Update logo in Redis cache
104+ if ( logo ) {
105+ await redis . set ( `brand:logo:${ teamId } ` , logo ) ;
106+ } else {
107+ // If logo is null or undefined, delete the cache
108+ await redis . del ( `brand:logo:${ teamId } ` ) ;
109+ }
110+
97111 return res . status ( 200 ) . json ( brand ) ;
98112 } else if ( req . method === "DELETE" ) {
99113 // DELETE /api/teams/:teamId/branding
@@ -116,6 +130,9 @@ export default async function handle(
116130 } ,
117131 } ) ;
118132
133+ // Remove logo from Redis cache
134+ await redis . del ( `brand:logo:${ teamId } ` ) ;
135+
119136 return res . status ( 204 ) . end ( ) ;
120137 } else {
121138 // We only allow GET and DELETE requests
0 commit comments