diff --git a/apps/dashboard/app/(app)/settings/root-keys/new/client.tsx b/apps/dashboard/app/(app)/settings/root-keys/new/client.tsx index 9ed8d82c58..a4cf818566 100644 --- a/apps/dashboard/app/(app)/settings/root-keys/new/client.tsx +++ b/apps/dashboard/app/(app)/settings/root-keys/new/client.tsx @@ -22,12 +22,12 @@ import { Label } from "@/components/ui/label"; import { toast } from "@/components/ui/toaster"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { trpc } from "@/lib/trpc/client"; -import { unkeyPermissionValidation, type UnkeyPermission } from "@unkey/rbac"; +import { type UnkeyPermission, unkeyPermissionValidation } from "@unkey/rbac"; import { ChevronRight } from "lucide-react"; import { useRouter } from "next/navigation"; +import { createParser, parseAsArrayOf, useQueryState } from "nuqs"; import { useEffect, useState } from "react"; import { apiPermissions, workspacePermissions } from "../[keyId]/permissions/permissions"; -import { createParser, parseAsArrayOf, useQueryState } from "nuqs"; type Props = { apis: { @@ -54,7 +54,7 @@ export const Client: React.FC = ({ apis }) => { history: "push", shallow: false, // otherwise server components won't notice the change clearOnDefault: true, - }) + }), ); const key = trpc.rootKey.create.useMutation({ @@ -94,13 +94,15 @@ export const Client: React.FC = ({ apis }) => { })); }; - useEffect(() => { + useEffect(() => { const initialSelectedApiSet = new Set(); selectedPermissions.forEach((permission) => { - const apiId = permission.split('.')[1] ?? ''; // Extract API ID - if (apiId.length) initialSelectedApiSet.add(apiId); + const apiId = permission.split(".")[1] ?? ""; // Extract API ID + if (apiId.length) { + initialSelectedApiSet.add(apiId); + } }); - + const initialCardStates: Record = {}; apis.forEach((api) => { initialCardStates[api.id] = initialSelectedApiSet.has(api.id); // O(1) check diff --git a/apps/www/app/templates/data.ts b/apps/www/app/templates/data.ts index e9a23e5a1a..c5fcca3c70 100644 --- a/apps/www/app/templates/data.ts +++ b/apps/www/app/templates/data.ts @@ -48,6 +48,17 @@ export type Template = { }; export const templates: Record = { + "cost-ratelimit": { + title: "Cost based Ratelimiting", + description: "Ratelimit your AI application based on estimated cost", + authors: ["unrenamed"], + repository: "https://github.com/harshsbhat/ordox", + image: "/images/templates/cost-ratelimit.png", + readmeUrl: "https://raw.githubusercontent.com/harshsbhat/ordox/refs/heads/main/README.md", + url: "https://ordox.vercel.app", + language: "Typescript", + framework: "Next.js", + }, "pdf-view": { title: "Protecting Digital Content Access", description: diff --git a/apps/www/public/images/templates/cost-ratelimit.png b/apps/www/public/images/templates/cost-ratelimit.png new file mode 100644 index 0000000000..5b88891177 Binary files /dev/null and b/apps/www/public/images/templates/cost-ratelimit.png differ diff --git a/oss.gg/7_create_a_template.md b/oss.gg/7_create_a_template.md index 7fce1f9975..8f28531802 100644 --- a/oss.gg/7_create_a_template.md +++ b/oss.gg/7_create_a_template.md @@ -31,4 +31,6 @@ Your turn 👇 » 04-October-2024 by Nazar Poshtarenko [Time-Sensitive API Keys for Digital Content Access](https://github.com/unrenamed/unkey-pdf-view.git) +» 06-October-2024 by Harsh Bhat [Cost Based ratelimiting](https://github.com/harshsbhat/ordox) [Live](https://ordox.vercel.app/) + ---