cal.pub0.org/pages/api/api-keys/[id]/_get.ts

16 lines
562 B
TypeScript
Raw Normal View History

import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server";
2022-12-08 23:28:28 +00:00
import { apiKeyPublicSchema } from "~/lib/validations/api-key";
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
async function getHandler(req: NextApiRequest) {
const { prisma, query } = req;
const { id } = schemaQueryIdAsString.parse(query);
const api_key = await prisma.apiKey.findUniqueOrThrow({ where: { id } });
return { api_key: apiKeyPublicSchema.parse(api_key) };
}
export default defaultResponder(getHandler);