2022-03-25 19:17:37 +00:00
|
|
|
import prisma from "@calcom/prisma";
|
|
|
|
|
2022-03-26 04:28:53 +00:00
|
|
|
import { ApiKey } from "@prisma/client";
|
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
2022-03-25 18:37:51 +00:00
|
|
|
|
|
|
|
type ResponseData = {
|
|
|
|
data?: ApiKey[];
|
|
|
|
error?: unknown;
|
2022-03-26 04:28:53 +00:00
|
|
|
message?: string;
|
2022-03-25 18:37:51 +00:00
|
|
|
};
|
|
|
|
|
2022-03-26 04:28:53 +00:00
|
|
|
export default async function apiKeys(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
|
|
|
|
const { method } = req;
|
|
|
|
if (method === "GET") {
|
2022-03-28 14:05:00 +00:00
|
|
|
const data = await prisma.apiKey.findMany({});
|
|
|
|
res.status(200).json({ data });
|
2022-03-26 23:58:22 +00:00
|
|
|
} else res.status(405).json({ message: "Only GET Method allowed" });
|
2022-03-25 18:37:51 +00:00
|
|
|
}
|