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

Commit

Permalink
botway(core): add ai prompt input
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Jul 7, 2023
1 parent 99ac4dc commit ae22877
Show file tree
Hide file tree
Showing 45 changed files with 336 additions and 264 deletions.
4 changes: 2 additions & 2 deletions assets/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const add = () => {
data.map(async (d) => {
const response = await fetch(
`${Deno.env.get(
"NEXT_PUBLIC_SUPABASE_URL"
)}/storage/v1/object/public/cdn/${v}/${d.name}`
"NEXT_PUBLIC_SUPABASE_URL",
)}/storage/v1/object/public/cdn/${v}/${d.name}`,
);

if (!response.ok) throw new Error("Response not OK");
Expand Down
2 changes: 1 addition & 1 deletion assets/supabase/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ const options = {
export const supabase = createClient(
Deno.env.get("NEXT_PUBLIC_SUPABASE_URL"),
Deno.env.get("NEXT_PUBLIC_SUPABASE_ANON_KEY"),
options
options,
);
25 changes: 0 additions & 25 deletions core/app/ai/new/page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions core/app/api/ai/generator/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export async function POST(request: Request) {

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

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

const octokit = new Octokit({
Expand Down
6 changes: 3 additions & 3 deletions core/app/api/ce/enable/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export async function POST(request: Request) {

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

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

const { payload: password } = await jwtDecrypt(body.password, BW_SECRET_KEY);
Expand All @@ -46,7 +46,7 @@ export async function POST(request: Request) {

const { payload: railwayProjectId } = await jwtDecrypt(
data.railway_project_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const octokit = new Octokit({
Expand Down
8 changes: 4 additions & 4 deletions core/app/api/ce/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export async function POST(request: Request) {

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

const { payload: railwayProjectId } = await jwtDecrypt(
body.railwayProjectId,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const query = `
Expand Down Expand Up @@ -87,8 +87,8 @@ export async function POST(request: Request) {
srv.node.serviceInstances.edges.find(
(si: any) =>
si.node.source.template?.serviceSource ===
"https://github.com/botwayorg/ce"
)
"https://github.com/botwayorg/ce",
),
).node.serviceInstances.edges[0].node.domains;

let domain;
Expand Down
8 changes: 4 additions & 4 deletions core/app/api/deployments/logs/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export async function GET(request: Request) {

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

const { payload: railwayServiceId } = await jwtDecrypt(
data.railway_service_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const deployments = await fetcher(
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function GET(request: Request) {
}
`,
}),
}
},
);

if (deployments.errors) {
Expand All @@ -85,7 +85,7 @@ export async function GET(request: Request) {
new Date(b.node.createdAt).getTime() -
new Date(a.node.createdAt).getTime()
);
}
},
);

const logs = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down
8 changes: 4 additions & 4 deletions core/app/api/deployments/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export async function GET(request: Request) {

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

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

const deployments = await fetcher(
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function GET(request: Request) {
}
`,
}),
}
},
);

if (deployments.errors) {
Expand All @@ -82,7 +82,7 @@ export async function GET(request: Request) {
new Date(b.node.createdAt).getTime() -
new Date(a.node.createdAt).getTime()
);
}
},
);

return NextResponse.json(dy);
Expand Down
6 changes: 3 additions & 3 deletions core/app/api/integrations/add/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export async function POST(request: Request) {

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

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

const { payload: projectId } = await jwtDecrypt(
body.projectId,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const octokit = new Octokit({
Expand Down
2 changes: 1 addition & 1 deletion core/app/api/integrations/x/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function GET(request: Request) {
`https://cdn-botway.deno.dev/integrations/${slug}`,
{
method: "GET",
}
},
);

return NextResponse.json(intx);
Expand Down
10 changes: 5 additions & 5 deletions core/app/api/projects/config/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export async function POST(request: Request) {

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

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

const { payload: bt } = await jwtDecrypt(body.botToken, BW_SECRET_KEY);
Expand All @@ -53,12 +53,12 @@ export async function POST(request: Request) {

const { payload: railwayProjectId } = await jwtDecrypt(
body.railwayProjectId,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const { payload: railwayServiceId } = await jwtDecrypt(
body.railwayServiceId,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const getEnvId = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down Expand Up @@ -90,7 +90,7 @@ export async function POST(request: Request) {
}

const envId = getEnvId.data.project.environments.edges.find(
(env: any) => env.node.name === "production"
(env: any) => env.node.name === "production",
).node.id;

let vars;
Expand Down
8 changes: 4 additions & 4 deletions core/app/api/projects/env/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function POST(request: Request) {

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

const { data, error } = await supabase
Expand All @@ -37,12 +37,12 @@ export async function POST(request: Request) {

const { payload: railwayProjectId } = await jwtDecrypt(
data.railway_project_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const { payload: railwayServiceId } = await jwtDecrypt(
data.railway_service_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const getEnvId = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function POST(request: Request) {
}

const envId = getEnvId.data.project.environments.edges.find(
(env: any) => env.node.name === "production"
(env: any) => env.node.name === "production",
).node.id;

const getVars = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down
8 changes: 4 additions & 4 deletions core/app/api/projects/env/update/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function POST(request: Request) {

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

const { data, error } = await supabase
Expand All @@ -37,12 +37,12 @@ export async function POST(request: Request) {

const { payload: railwayProjectId } = await jwtDecrypt(
data.railway_project_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const { payload: railwayServiceId } = await jwtDecrypt(
data.railway_service_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const { payload: value } = await jwtDecrypt(body.value, BW_SECRET_KEY);
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function POST(request: Request) {
}

const envId = getEnvId.data.project.environments.edges.find(
(env: any) => env.node.name === "production"
(env: any) => env.node.name === "production",
).node.id;

const updateVar = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down
16 changes: 8 additions & 8 deletions core/app/api/projects/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export async function POST(request: Request) {

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

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

const createRailwayProject = await fetcher(
Expand All @@ -53,7 +53,7 @@ export async function POST(request: Request) {
}
`,
}),
}
},
);

if (createRailwayProject.errors) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function POST(request: Request) {
}
`,
}),
}
},
);

if (createService.errors) {
Expand Down Expand Up @@ -136,12 +136,12 @@ export async function POST(request: Request) {

exec(
`create-botway-bot ${stringify(body.name)} ${stringify(
body.platform
body.platform,
)} ${stringify(body.lang)} ${stringify(
body.package_manager
body.package_manager,
)} railway ${stringify(githubApiToken.data)} ${stringify(
ghu.login
)} ${stringify(ghu.email)}`
ghu.login,
)} ${stringify(ghu.email)}`,
)
.on("error", (error) => {
return NextResponse.json({ error: error.message });
Expand Down
6 changes: 3 additions & 3 deletions core/app/api/projects/services/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export async function POST(request: Request) {

const { payload: railwayProjectId } = await jwtDecrypt(
data.railway_project_id,
BW_SECRET_KEY
BW_SECRET_KEY,
);

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

const projectData = await fetcher(
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function POST(request: Request) {
}
`,
}),
}
},
);

if (projectData.errors) {
Expand Down
4 changes: 2 additions & 2 deletions core/app/api/projects/settings/delete/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export async function POST(request: Request) {

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

const { payload: railwayProjectId } = await jwtDecrypt(
body.railwayProjectId,
BW_SECRET_KEY
BW_SECRET_KEY,
);

const deleteBot = await fetcher("https://backboard.railway.app/graphql/v2", {
Expand Down
Loading

0 comments on commit ae22877

Please sign in to comment.