Files
zerobyte/app/server/modules/api-keys/api-key-metadata.ts
Nico 283de054ec feat(authentication): api key (#966)
* feat(authentication): api key

Keeps selected UX pieces from b487b096.

Co-authored-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg>

* refactor: pr feedbacks

* chore: bump @better-auth/api-key

* refactor: global limit of 50 api key instead of 10 per org

---------

Co-authored-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg>
2026-06-12 20:14:21 +02:00

13 lines
375 B
TypeScript

import { safeJsonParse } from "@zerobyte/core/utils";
import { z } from "zod";
const apiKeyMetadataSchema = z.object({
organizationId: z.string(),
});
export const parseApiKeyOrganizationId = (metadata: string | null | undefined) => {
const parsed = apiKeyMetadataSchema.safeParse(safeJsonParse(metadata));
return parsed.success ? parsed.data.organizationId : null;
};