2022-03-30 12:17:55 +00:00
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
2022-03-25 19:17:37 +00:00
|
|
|
|
2022-03-30 12:17:55 +00:00
|
|
|
import prisma from "@calcom/prisma";
|
2022-03-29 01:59:57 +00:00
|
|
|
import { ApiKey } from "@calcom/prisma/client";
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-03-29 01:59:57 +00:00
|
|
|
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
2022-03-25 18:37:51 +00:00
|
|
|
|
|
|
|
type ResponseData = {
|
|
|
|
data?: ApiKey[];
|
|
|
|
error?: unknown;
|
|
|
|
};
|
|
|
|
|
2022-03-29 01:59:57 +00:00
|
|
|
async function allApiKeys(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
|
|
|
|
const data = await prisma.apiKey.findMany();
|
|
|
|
|
|
|
|
if (data) res.status(200).json({ data });
|
|
|
|
else res.status(400).json({ error: "No data found" });
|
2022-03-25 18:37:51 +00:00
|
|
|
}
|
2022-03-29 01:59:57 +00:00
|
|
|
|
2022-03-30 12:17:55 +00:00
|
|
|
export default withMiddleware("addRequestId", "HTTP_GET")(allApiKeys);
|