diff --git a/apps/dokploy/pages/api/redirect.ts b/apps/dokploy/pages/api/redirect.ts deleted file mode 100644 index 785b078c..00000000 --- a/apps/dokploy/pages/api/redirect.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { db } from "@/server/db"; -import { admins } from "@/server/db/schema"; -import { eq } from "drizzle-orm"; -import type { NextApiRequest, NextApiResponse } from "next"; -import { Octokit } from "octokit"; - -type Query = { - code: string; - state: string; - installation_id: string; - setup_action: string; -}; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - const { code, state, installation_id, setup_action }: Query = - req.query as Query; - if (!code) { - return res.status(400).json({ error: "Missing code parameter" }); - } - const [action, authId] = state?.split(":"); - - if (action === "gh_init") { - const octokit = new Octokit({}); - const { data } = await octokit.request( - "POST /app-manifests/{code}/conversions", - { - code: code as string, - }, - ); - - const result = await db - .update(admins) - .set({ - githubAppId: data.id, - githubAppName: data.html_url, - githubClientId: data.client_id, - githubClientSecret: data.client_secret, - githubWebhookSecret: data.webhook_secret, - githubPrivateKey: data.pem, - }) - .where(eq(admins.authId, authId as string)) - .returning(); - } else if (action === "gh_setup") { - await db - .update(admins) - .set({ - githubInstallationId: installation_id, - }) - .where(eq(admins.authId, authId as string)) - .returning(); - } - - res.redirect(307, "/dashboard/settings/server"); -} diff --git a/apps/dokploy/pages/api/webhook.ts b/apps/dokploy/pages/api/webhook.ts deleted file mode 100644 index ccc3536a..00000000 --- a/apps/dokploy/pages/api/webhook.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from "next"; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - if (req.method === "POST") { - const xGitHubEvent = req.headers["x-github-event"]; - - if (xGitHubEvent === "ping") { - res.redirect(307, "/dashboard/settings"); - } else { - res.redirect(307, "/dashboard/settings"); - } - } else { - res.setHeader("Allow", ["POST"]); - return res.status(405).end(`Method ${req.method} not allowed`); - } -}