Skip to content

Commit

Permalink
Revert "feat: use redis server"
Browse files Browse the repository at this point in the history
This reverts commit aeff086.
  • Loading branch information
yongenaelf committed Nov 13, 2024
1 parent aeff086 commit ac68c1c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BUILD_SERVER_BASE_URL=
SOLANG_BUILD_SERVER_BASE_URL=
BUILD_SERVER_BASE_URL=https://playground.test.aelf.dev
SOLANG_BUILD_SERVER_BASE_URL=https://playground-next.test.aelf.dev
SOLIDITY_ENABLED=false
GA_TAG=
GITHUB_API_KEY=
4 changes: 2 additions & 2 deletions app/api/build/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function POST(request: NextRequest) {
const formData = new FormData();
const filePath = uuidv4() + ".zip";
formData.append(
"file",
"contractFiles",
new File([zippedData], filePath, { type: "application/zip" }),
filePath
);
Expand All @@ -26,7 +26,7 @@ export async function POST(request: NextRequest) {
};

const response = await fetch(
`${getBuildServerBaseUrl()}/build`,
`${getBuildServerBaseUrl()}/playground/build`,
requestInit
);

Expand Down
11 changes: 6 additions & 5 deletions app/api/get-share/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FileContent } from "@/data/db";
import { unzipBlob } from "@/data/unzip-blob";
import { getBuildServerBaseUrl } from "@/lib/env";
import { strFromU8 } from "fflate";
import { unzipSync, strFromU8 } from "fflate";

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
Expand All @@ -12,11 +11,13 @@ export async function GET(request: Request) {
}

try {
const res = await fetch(`${getBuildServerBaseUrl()}/share/get?key=${id}`);
const res = await fetch(
`${getBuildServerBaseUrl()}/playground/share/get/${id}`
);

const blob = await res.blob();
const data = await res.arrayBuffer();

const unzipped = await unzipBlob(blob);
const unzipped = unzipSync(Buffer.from(data));

let files: FileContent[] = [];

Expand Down
2 changes: 1 addition & 1 deletion app/api/get-template-data/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function GET(request: Request) {
throw new Error("no name");
}

const res = await getTemplateData(id);
const res = await getTemplateData(id, name);

const data = Object.entries(res).map(([key, value]) => ({
path: encodeURIComponent(key),
Expand Down
4 changes: 2 additions & 2 deletions app/api/share/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
};

const response = await fetch(
`${getBuildServerBaseUrl()}/share/create`,
`${getBuildServerBaseUrl()}/playground/share/create`,
requestInit
);

Expand All @@ -33,5 +33,5 @@ export async function POST(request: NextRequest) {
return Response.json({ error: message }, { status: response.status });
}

return Response.json({ id: await response.text() });
return Response.json(await response.json());
}
4 changes: 2 additions & 2 deletions app/api/test/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function POST(request: NextRequest) {
const formData = new FormData();
const filePath = uuidv4() + ".zip";
formData.append(
"file",
"contractFiles",
new File([zippedData], filePath, { type: "application/zip" }),
filePath
);
Expand All @@ -25,7 +25,7 @@ export async function POST(request: NextRequest) {
};

const response = await fetch(
`${getBuildServerBaseUrl()}/test`,
`${getBuildServerBaseUrl()}/playground/test`,
requestInit
);

Expand Down
5 changes: 4 additions & 1 deletion components/workspace/format-errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { processTestOutput } from "./process-test-output";
export function FormatErrors({ inputString }: { inputString?: string }) {
if (!inputString) return "";
// Detect and remove the dynamic path
const cleanedString = inputString.replace(/\/tmp\/[a-f0-9\-]+\//g, "");
const cleanedString = inputString.replace(
/\/tmp\/playground\/[a-f0-9\-]+\//g,
""
);

// Regular expression to match lines containing errors and warnings
const errorMessages = cleanedString.match(
Expand Down
17 changes: 11 additions & 6 deletions data/template.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { getBuildServerBaseUrl } from "@/lib/env";
import { unzipBlob } from "./unzip-blob";
import { unzipSync } from "fflate";

export async function getTemplateData(id: string) {
const res = await fetch(`${getBuildServerBaseUrl()}/template?template=${id}`);
export async function getTemplateData(id: string, name: string = "test") {
const res = await fetch(
`${getBuildServerBaseUrl()}/playground/template?template=${id}&projectName=${name}`
);

const blob = await res.blob();
return unzipBlob(blob);
const data = await res.text();

const zipData = Buffer.from(data, "base64");

return unzipSync(zipData);
}

export async function getTemplateNames() {
const res = await fetch(`${getBuildServerBaseUrl()}/templates`);
const res = await fetch(`${getBuildServerBaseUrl()}/playground/templates`);
const data = await res.json();

return data as string[];
Expand Down
6 changes: 0 additions & 6 deletions data/unzip-blob.ts

This file was deleted.

0 comments on commit ac68c1c

Please sign in to comment.