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

Commit

Permalink
botway(core): start implementing AI for botway
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Jul 1, 2023
1 parent 608259f commit 408bff7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 23 deletions.
41 changes: 41 additions & 0 deletions core/app/api/ai/generator/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { NextResponse } from "next/server";
import { fetcher } from "@/tools/fetch";
import { jwtDecrypt } from "jose";
import { BW_SECRET_KEY } from "@/tools/tokens";
import createClient from "@/supabase/server";
import { Octokit } from "octokit";

export const revalidate = 0;

export async function POST(request: Request) {
const body = await request.json();

const supabase = createClient();

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

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

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

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

const octokit = new Octokit({
auth: githubApiToken.data,
});

const ghu = await (await octokit.request("GET /user", {})).data;

return NextResponse.json({ message: "Success" });
}
22 changes: 22 additions & 0 deletions core/app/api/ai/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NextResponse } from "next/server";
import { fetcher } from "@/tools/fetch";
import createClient from "@/supabase/server";

export const revalidate = 0;

export async function POST(request: Request) {
const body = await request.json();

const supabase = createClient();

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

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

return NextResponse.json({ message: "Success" });
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"packageManager": "[email protected]",
"devDependencies": {
"prettier": "^2.8.8",
"turbo": "^1.10.6"
"turbo": "^1.10.7"
}
}
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 408bff7

Please sign in to comment.