From 7fcc270fe828d3b97151bb73aa97e8be4e65b9c9 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 8 Apr 2022 23:20:52 +0200 Subject: [PATCH] adds index with message redirecting users to docs just so checkly doesn't fail --- pages/api/_middleware.ts | 21 --------------------- pages/api/index.ts | 5 +++++ 2 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 pages/api/_middleware.ts create mode 100644 pages/api/index.ts diff --git a/pages/api/_middleware.ts b/pages/api/_middleware.ts deleted file mode 100644 index 35529757ba..0000000000 --- a/pages/api/_middleware.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; - -// Not much useful yet as prisma.client can't be used in the middlewares (client is not available) -// For now we just throw early if no apiKey is passed, -// but we could also check if the apiKey is valid if we had prisma here. - -export default async function requireApiKeyAsQueryParams({ nextUrl }: NextRequest) { - const response = NextResponse.next(); - const apiKey = nextUrl.searchParams.get("apiKey"); - - if (apiKey) return response; - // if no apiKey is passed, we throw early a 401 unauthorized asking for a valid apiKey - else - new NextResponse( - JSON.stringify({ - message: - "You need to pass an apiKey as query param: https://api.cal.com/resource?apiKey=", - }), - { status: 401, statusText: "Unauthorized" } - ); -} diff --git a/pages/api/index.ts b/pages/api/index.ts new file mode 100644 index 0000000000..17d29ee64b --- /dev/null +++ b/pages/api/index.ts @@ -0,0 +1,5 @@ +import type { NextApiRequest, NextApiResponse } from "next"; + +export default async function CalcomApi(req: NextApiRequest, res: NextApiResponse) { + res.status(201).json({ message: "Welcome to Cal.com API - docs are at https://docs.cal.com/api" }); +}