mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 10:19:51 -06:00
Co-authored-by: Victor Santos <victor@formbricks.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
35 lines
761 B
TypeScript
35 lines
761 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
hashedKey?: string;
|
|
organizationId?: string;
|
|
}
|
|
|
|
export const apiKeyCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `apiKeys-${id}`;
|
|
},
|
|
byHashedKey(hashedKey: string) {
|
|
return `apiKeys-${hashedKey}-apiKey`;
|
|
},
|
|
byOrganizationId(organizationId: string) {
|
|
return `organizations-${organizationId}-apiKeys`;
|
|
},
|
|
},
|
|
revalidate({ id, hashedKey, organizationId }: RevalidateProps): void {
|
|
if (id) {
|
|
revalidateTag(this.tag.byId(id));
|
|
}
|
|
|
|
if (hashedKey) {
|
|
revalidateTag(this.tag.byHashedKey(hashedKey));
|
|
}
|
|
|
|
if (organizationId) {
|
|
revalidateTag(this.tag.byOrganizationId(organizationId));
|
|
}
|
|
},
|
|
};
|