mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: simplify naming schema
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { findAdmin } from "@/server/api/services/admin";
|
||||
import { db } from "@/server/db";
|
||||
import { applications, compose, githubProvider } from "@/server/db/schema";
|
||||
import { applications, compose } from "@/server/db/schema";
|
||||
import type { DeploymentJob } from "@/server/queues/deployments-queue";
|
||||
import { myQueue } from "@/server/queues/queueSetup";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
@@ -22,13 +22,13 @@ export default async function handler(
|
||||
const signature = req.headers["x-hub-signature-256"];
|
||||
const github = req.body;
|
||||
|
||||
if(!github?.installation.id) {
|
||||
if (!github?.installation.id) {
|
||||
res.status(400).json({ message: "Github Installation not found" });
|
||||
return;
|
||||
}
|
||||
|
||||
const githubResult = await db.query.githubProvider.findFirst({
|
||||
where: eq(githubProvider.githubInstallationId, github.installation.id),
|
||||
const githubResult = await db.query.github.findFirst({
|
||||
where: eq(github.githubInstallationId, github.installation.id),
|
||||
});
|
||||
|
||||
if (!githubResult) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createGithubProvider } from "@/server/api/services/git-provider";
|
||||
import { createGithub } from "@/server/api/services/git-provider";
|
||||
import { db } from "@/server/db";
|
||||
import { githubProvider } from "@/server/db/schema";
|
||||
import { github } from "@/server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { Octokit } from "octokit";
|
||||
@@ -34,7 +34,7 @@ export default async function handler(
|
||||
},
|
||||
);
|
||||
|
||||
await createGithubProvider({
|
||||
await createGithub({
|
||||
name: data.name,
|
||||
githubAppName: data.html_url,
|
||||
githubAppId: data.id,
|
||||
@@ -46,11 +46,11 @@ export default async function handler(
|
||||
});
|
||||
} else if (action === "gh_setup") {
|
||||
await db
|
||||
.update(githubProvider)
|
||||
.update(github)
|
||||
.set({
|
||||
githubInstallationId: installation_id,
|
||||
})
|
||||
.where(eq(githubProvider.githubId, value as string))
|
||||
.where(eq(github.githubId, value as string))
|
||||
.returning();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
getGitlabProvider,
|
||||
updateGitlabProvider,
|
||||
findGitlabById,
|
||||
updateGitlab,
|
||||
} from "@/server/api/services/git-provider";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
@@ -14,7 +14,7 @@ export default async function handler(
|
||||
return res.status(400).json({ error: "Missing or invalid code" });
|
||||
}
|
||||
|
||||
const gitlab = await getGitlabProvider(gitlabId as string);
|
||||
const gitlab = await findGitlabById(gitlabId as string);
|
||||
|
||||
const response = await fetch("https://gitlab.com/oauth/token", {
|
||||
method: "POST",
|
||||
@@ -37,7 +37,7 @@ export default async function handler(
|
||||
}
|
||||
|
||||
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
|
||||
await updateGitlabProvider(gitlab.gitlabId, {
|
||||
await updateGitlab(gitlab.gitlabId, {
|
||||
accessToken: result.access_token,
|
||||
refreshToken: result.refresh_token,
|
||||
expiresAt,
|
||||
|
||||
Reference in New Issue
Block a user