mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
remove
This commit is contained in:
parent
f05c811bdc
commit
2ec364ed68
@ -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");
|
||||
}
|
@ -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`);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user