From 30e1c39d6c2f1164368221ce1159d3ed15571e6a Mon Sep 17 00:00:00 2001 From: Ishaan Dey Date: Thu, 23 May 2024 23:52:30 -0700 Subject: [PATCH] type fixes --- backend/database/src/index.ts | 2 +- backend/server/src/index.ts | 4 +- backend/server/src/types.ts | 100 +++++++++--------- backend/server/src/utils.ts | 4 +- frontend/app/globals.css | 8 +- .../dashboard/projectCard/index.tsx | 4 +- frontend/lib/types.ts | 90 ++++++++-------- 7 files changed, 109 insertions(+), 103 deletions(-) diff --git a/backend/database/src/index.ts b/backend/database/src/index.ts index dc51770..314c9d0 100644 --- a/backend/database/src/index.ts +++ b/backend/database/src/index.ts @@ -92,7 +92,7 @@ export default { return new Response("You reached the maximum # of sandboxes.", { status: 400 }); } - const sb = await db.insert(sandbox).values({ type, name, userId, visibility }).returning().get(); + const sb = await db.insert(sandbox).values({ type, name, userId, visibility, createdAt: new Date() }).returning().get(); const initStorageRequest = new Request("https://storage.ishaan1013.workers.dev/api/init", { method: "POST", diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 9be0f6d..c4195d3 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -343,6 +343,7 @@ io.on("connection", async (socket) => { const onExit = pty.onExit((code) => console.log("exit :(", code)); pty.write("clear\r"); + pty.write("export PS1='> '\r"); terminals[id] = { terminal: pty, @@ -457,7 +458,8 @@ io.on("connection", async (socket) => { io.fetchSockets().then(async (sockets) => { if (sockets.length === 0) { console.log("Closing server due to inactivity."); - // const res = await stopServer(data.sandboxId, data.userId); + const res = await stopServer(data.sandboxId); + console.log("Server stopped", res); } }); }, 20000); diff --git a/backend/server/src/types.ts b/backend/server/src/types.ts index 7a847d4..b71592a 100644 --- a/backend/server/src/types.ts +++ b/backend/server/src/types.ts @@ -1,68 +1,70 @@ // DB Types export type User = { - id: string - name: string - email: string - generations: number - sandbox: Sandbox[] - usersToSandboxes: UsersToSandboxes[] -} + id: string; + name: string; + email: string; + generations: number; + sandbox: Sandbox[]; + usersToSandboxes: UsersToSandboxes[]; +}; export type Sandbox = { - id: string - name: string - type: "react" | "node" - visibility: "public" | "private" - userId: string - usersToSandboxes: UsersToSandboxes[] -} + id: string; + name: string; + type: "react" | "node"; + visibility: "public" | "private"; + createdAt: Date; + userId: string; + usersToSandboxes: UsersToSandboxes[]; +}; export type UsersToSandboxes = { - userId: string - sandboxId: string -} + userId: string; + sandboxId: string; + sharedOn: Date; +}; export type TFolder = { - id: string - type: "folder" - name: string - children: (TFile | TFolder)[] -} + id: string; + type: "folder"; + name: string; + children: (TFile | TFolder)[]; +}; export type TFile = { - id: string - type: "file" - name: string -} + id: string; + type: "file"; + name: string; +}; export type TFileData = { - id: string - data: string -} + id: string; + data: string; +}; export type R2Files = { - objects: R2FileData[] - truncated: boolean - delimitedPrefixes: any[] -} + objects: R2FileData[]; + truncated: boolean; + delimitedPrefixes: any[]; +}; export type R2FileData = { - storageClass: string - uploaded: string - checksums: any - httpEtag: string - etag: string - size: number - version: string - key: string -} + storageClass: string; + uploaded: string; + checksums: any; + httpEtag: string; + etag: string; + size: number; + version: string; + key: string; +}; export type R2FileBody = R2FileData & { - body: ReadableStream - bodyUsed: boolean - arrayBuffer: Promise - text: Promise - json: Promise - blob: Promise -} + body: ReadableStream; + bodyUsed: boolean; + arrayBuffer: Promise; + text: Promise; + json: Promise; + blob: Promise; +}; diff --git a/backend/server/src/utils.ts b/backend/server/src/utils.ts index 6bb7076..b0fd47e 100644 --- a/backend/server/src/utils.ts +++ b/backend/server/src/utils.ts @@ -179,14 +179,14 @@ export const getProjectSize = async (id: string) => { export const stopServer = async (service: string) => { const command = new DeleteServiceCommand({ - cluster: "Sandbox", + cluster: process.env.AWS_ECS_CLUSTER!, service, force: true, }); try { const response = await client.send(command); - console.log("Stopped server:", response); + return response; } catch (error) { console.error("Error stopping server:", error); } diff --git a/frontend/app/globals.css b/frontend/app/globals.css index 26f37fb..e641278 100644 --- a/frontend/app/globals.css +++ b/frontend/app/globals.css @@ -78,15 +78,15 @@ .gradient-button-bg { background: radial-gradient( circle at top, - #a5b4fc 0%, - #3730a3 50% + #d4d4d4 0%, + #262626 50% ); /* violet 300 -> 800 */ } .gradient-button { background: radial-gradient( circle at bottom, - #312e81 -10%, + #262626 -10%, hsl(0 0% 3.9%) 50% ); /* violet 900 -> bg */ } @@ -94,7 +94,7 @@ .gradient-button-bg > div:hover { background: radial-gradient( circle at bottom, - #312e81 -10%, + #262626 -10%, hsl(0 0% 3.9%) 80% ); /* violet 900 -> bg */ } diff --git a/frontend/components/dashboard/projectCard/index.tsx b/frontend/components/dashboard/projectCard/index.tsx index 62212df..8a97829 100644 --- a/frontend/components/dashboard/projectCard/index.tsx +++ b/frontend/components/dashboard/projectCard/index.tsx @@ -33,7 +33,7 @@ export default function ProjectCard({ onMouseLeave={() => setHovered(false)} className={`group/canvas-card p-4 h-48 flex flex-col justify-between items-start hover:border-muted-foreground/50 relative overflow-hidden transition-all`} > - + {/* {hovered && ( )} - + */}