type fixes

This commit is contained in:
Ishaan Dey 2024-05-23 23:52:30 -07:00
parent 1528ea5257
commit 30e1c39d6c
7 changed files with 109 additions and 103 deletions

View File

@ -92,7 +92,7 @@ export default {
return new Response("You reached the maximum # of sandboxes.", { status: 400 }); 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", { const initStorageRequest = new Request("https://storage.ishaan1013.workers.dev/api/init", {
method: "POST", method: "POST",

View File

@ -343,6 +343,7 @@ io.on("connection", async (socket) => {
const onExit = pty.onExit((code) => console.log("exit :(", code)); const onExit = pty.onExit((code) => console.log("exit :(", code));
pty.write("clear\r"); pty.write("clear\r");
pty.write("export PS1='> '\r");
terminals[id] = { terminals[id] = {
terminal: pty, terminal: pty,
@ -457,7 +458,8 @@ io.on("connection", async (socket) => {
io.fetchSockets().then(async (sockets) => { io.fetchSockets().then(async (sockets) => {
if (sockets.length === 0) { if (sockets.length === 0) {
console.log("Closing server due to inactivity."); 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); }, 20000);

View File

@ -1,68 +1,70 @@
// DB Types // DB Types
export type User = { export type User = {
id: string id: string;
name: string name: string;
email: string email: string;
generations: number generations: number;
sandbox: Sandbox[] sandbox: Sandbox[];
usersToSandboxes: UsersToSandboxes[] usersToSandboxes: UsersToSandboxes[];
} };
export type Sandbox = { export type Sandbox = {
id: string id: string;
name: string name: string;
type: "react" | "node" type: "react" | "node";
visibility: "public" | "private" visibility: "public" | "private";
userId: string createdAt: Date;
usersToSandboxes: UsersToSandboxes[] userId: string;
} usersToSandboxes: UsersToSandboxes[];
};
export type UsersToSandboxes = { export type UsersToSandboxes = {
userId: string userId: string;
sandboxId: string sandboxId: string;
} sharedOn: Date;
};
export type TFolder = { export type TFolder = {
id: string id: string;
type: "folder" type: "folder";
name: string name: string;
children: (TFile | TFolder)[] children: (TFile | TFolder)[];
} };
export type TFile = { export type TFile = {
id: string id: string;
type: "file" type: "file";
name: string name: string;
} };
export type TFileData = { export type TFileData = {
id: string id: string;
data: string data: string;
} };
export type R2Files = { export type R2Files = {
objects: R2FileData[] objects: R2FileData[];
truncated: boolean truncated: boolean;
delimitedPrefixes: any[] delimitedPrefixes: any[];
} };
export type R2FileData = { export type R2FileData = {
storageClass: string storageClass: string;
uploaded: string uploaded: string;
checksums: any checksums: any;
httpEtag: string httpEtag: string;
etag: string etag: string;
size: number size: number;
version: string version: string;
key: string key: string;
} };
export type R2FileBody = R2FileData & { export type R2FileBody = R2FileData & {
body: ReadableStream body: ReadableStream;
bodyUsed: boolean bodyUsed: boolean;
arrayBuffer: Promise<ArrayBuffer> arrayBuffer: Promise<ArrayBuffer>;
text: Promise<string> text: Promise<string>;
json: Promise<any> json: Promise<any>;
blob: Promise<Blob> blob: Promise<Blob>;
} };

View File

@ -179,14 +179,14 @@ export const getProjectSize = async (id: string) => {
export const stopServer = async (service: string) => { export const stopServer = async (service: string) => {
const command = new DeleteServiceCommand({ const command = new DeleteServiceCommand({
cluster: "Sandbox", cluster: process.env.AWS_ECS_CLUSTER!,
service, service,
force: true, force: true,
}); });
try { try {
const response = await client.send(command); const response = await client.send(command);
console.log("Stopped server:", response); return response;
} catch (error) { } catch (error) {
console.error("Error stopping server:", error); console.error("Error stopping server:", error);
} }

View File

@ -78,15 +78,15 @@
.gradient-button-bg { .gradient-button-bg {
background: radial-gradient( background: radial-gradient(
circle at top, circle at top,
#a5b4fc 0%, #d4d4d4 0%,
#3730a3 50% #262626 50%
); /* violet 300 -> 800 */ ); /* violet 300 -> 800 */
} }
.gradient-button { .gradient-button {
background: radial-gradient( background: radial-gradient(
circle at bottom, circle at bottom,
#312e81 -10%, #262626 -10%,
hsl(0 0% 3.9%) 50% hsl(0 0% 3.9%) 50%
); /* violet 900 -> bg */ ); /* violet 900 -> bg */
} }
@ -94,7 +94,7 @@
.gradient-button-bg > div:hover { .gradient-button-bg > div:hover {
background: radial-gradient( background: radial-gradient(
circle at bottom, circle at bottom,
#312e81 -10%, #262626 -10%,
hsl(0 0% 3.9%) 80% hsl(0 0% 3.9%) 80%
); /* violet 900 -> bg */ ); /* violet 900 -> bg */
} }

View File

@ -33,7 +33,7 @@ export default function ProjectCard({
onMouseLeave={() => setHovered(false)} 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`} 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`}
> >
<AnimatePresence> {/* <AnimatePresence>
{hovered && ( {hovered && (
<motion.div <motion.div
initial={{ opacity: 0 }} initial={{ opacity: 0 }}
@ -43,7 +43,7 @@ export default function ProjectCard({
{children} {children}
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence> */}
<div className="space-x-2 flex items-center justify-start w-full z-10"> <div className="space-x-2 flex items-center justify-start w-full z-10">
<Image <Image

View File

@ -1,63 +1,65 @@
// DB Types // DB Types
export type User = { export type User = {
id: string id: string;
name: string name: string;
email: string email: string;
generations: number generations: number;
sandbox: Sandbox[] sandbox: Sandbox[];
usersToSandboxes: UsersToSandboxes[] usersToSandboxes: UsersToSandboxes[];
} };
export type Sandbox = { export type Sandbox = {
id: string id: string;
name: string name: string;
type: "react" | "node" type: "react" | "node";
visibility: "public" | "private" visibility: "public" | "private";
userId: string createdAt: Date;
usersToSandboxes: UsersToSandboxes[] userId: string;
} usersToSandboxes: UsersToSandboxes[];
};
export type UsersToSandboxes = { export type UsersToSandboxes = {
userId: string userId: string;
sandboxId: string sandboxId: string;
} sharedOn: Date;
};
export type R2Files = { export type R2Files = {
objects: R2FileData[] objects: R2FileData[];
truncated: boolean truncated: boolean;
delimitedPrefixes: any[] delimitedPrefixes: any[];
} };
export type R2FileData = { export type R2FileData = {
storageClass: string storageClass: string;
uploaded: string uploaded: string;
checksums: any checksums: any;
httpEtag: string httpEtag: string;
etag: string etag: string;
size: number size: number;
version: string version: string;
key: string key: string;
} };
export type TFolder = { export type TFolder = {
id: string id: string;
type: "folder" type: "folder";
name: string name: string;
children: (TFile | TFolder)[] children: (TFile | TFolder)[];
} };
export type TFile = { export type TFile = {
id: string id: string;
type: "file" type: "file";
name: string name: string;
} };
export type TTab = TFile & { export type TTab = TFile & {
saved: boolean saved: boolean;
} };
export type TFileData = { export type TFileData = {
id: string id: string;
data: string data: string;
} };