Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
botway(core): update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Sep 1, 2023
1 parent 100dba0 commit 9dcea89
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 352 deletions.
80 changes: 80 additions & 0 deletions core/app/api/deployments/latest/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { NextResponse } from "next/server";
import { jwtDecrypt } from "jose";
import { BW_SECRET_KEY } from "@/tools/tokens";
import { fetcher } from "@/tools/fetch";
import createClient from "@/supabase/server";

export const revalidate = 0;

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);

const id = searchParams.get("id");

const supabase = createClient();

const {
data: { user: user },
error: userError,
} = await supabase.auth.getUser();

if (userError) {
return NextResponse.json({ error: userError });
}

const { data, error } = await supabase
.from("projects")
.select("zeabur_service_id, zeabur_env_id")
.eq("id", id)
.single();

if (error) {
return NextResponse.json({ error });
}

const { payload: zeaburApiToken } = await jwtDecrypt(
user?.user_metadata["zeaburApiToken"],
BW_SECRET_KEY,
);

const { payload: zeaburServiceId } = await jwtDecrypt(
data?.zeabur_service_id,
BW_SECRET_KEY,
);

const { payload: zeaburEnvId } = await jwtDecrypt(
data?.zeabur_env_id,
BW_SECRET_KEY,
);

const deployments = await fetcher("https://gateway.zeabur.com/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${zeaburApiToken.data}`,
},
body: JSON.stringify({
query: `
query {
deployments(
serviceID: "${zeaburServiceId.data}"
environmentID: "${zeaburEnvId.data}"
limit: 1
) {
edges {
node {
_id
}
}
}
}
`,
}),
});

if (deployments.errors) {
return NextResponse.json({ error: deployments.errors[0].message });
}

return NextResponse.json(deployments.data.deployments.edges[0].node._id);
}
149 changes: 0 additions & 149 deletions core/app/api/deployments/logs/route.ts

This file was deleted.

2 changes: 1 addition & 1 deletion core/app/project/[id]/code-editor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const CE = ({ user, projectId }: any) => {
user={user}
projectId={projectId}
projectName={project?.name}
projectRWID={project?.zeabur_project_id}
projectZBID={project?.zeabur_project_id}
>
<div className="mx-6 my-16 flex items-center space-x-6">
<h1 className="text-3xl text-white">Code Editor</h1>
Expand Down
2 changes: 1 addition & 1 deletion core/app/project/[id]/deployments/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const Project = ({ user, projectId }: any) => {
user={user}
projectId={projectId}
projectName={project?.name}
projectRWID={project?.zeabur_project_id}
projectZBID={project?.zeabur_project_id}
>
<div className="mx-6 my-16 flex items-center space-x-6">
<h1 className="text-3xl text-white">{project?.name} Deployments</h1>
Expand Down
2 changes: 1 addition & 1 deletion core/app/project/[id]/env/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const Env = ({ user, projectId }: any) => {
user={user}
projectId={projectId}
projectName={project?.name}
projectRWID={project?.zeabur_project_id}
projectZBID={project?.zeabur_project_id}
grid={true}
>
<div className="mx-6 my-16 flex items-center space-x-6">
Expand Down
2 changes: 1 addition & 1 deletion core/app/project/[id]/integrations/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const Project = ({ user, projectId, slug }: any) => {
user={user}
projectId={projectId}
projectName={project?.name}
projectRWID={project?.zeabur_project_id}
projectZBID={project?.zeabur_project_id}
grid={true}
>
<div className="mx-6 my-16 flex items-center space-x-6">
Expand Down
2 changes: 1 addition & 1 deletion core/app/project/[id]/integrations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const Project = ({ user, projectId }: any) => {
user={user}
projectId={projectId}
projectName={project?.name}
projectRWID={project?.zeabur_project_id}
projectZBID={project?.zeabur_project_id}
grid={true}
>
<div className="mx-6 my-16 flex items-center space-x-6">
Expand Down
Loading

0 comments on commit 9dcea89

Please sign in to comment.