2022-11-29 22:06:23 +00:00
|
|
|
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";
|
2022-11-29 22:06:23 +00:00
|
|
|
|
|
|
|
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);
|