diff --git a/backend/storage/package.json b/backend/storage/package.json
index 10aebf3..8b210b7 100644
--- a/backend/storage/package.json
+++ b/backend/storage/package.json
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"deploy": "wrangler deploy",
- "dev": "wrangler dev",
+ "dev": "wrangler dev --remote",
"start": "wrangler dev",
"test": "vitest",
"cf-typegen": "wrangler types"
diff --git a/backend/storage/src/index.ts b/backend/storage/src/index.ts
index 7571ed6..24d8569 100644
--- a/backend/storage/src/index.ts
+++ b/backend/storage/src/index.ts
@@ -24,13 +24,10 @@ export default {
const body = await request.json();
const { sandboxId, type } = initSchema.parse(body);
- // startercode.node.forEach(async (file) => {
- // await env.R2.put(`${sandboxId}/${file.name}`, file.body);
- // });
+ console.log(startercode[type]);
- // parallel data fetching with promise.all:
await Promise.all(
- startercode.node.map(async (file) => {
+ startercode[type].map(async (file) => {
await env.R2.put(`projects/${sandboxId}/${file.name}`, file.body);
})
);
diff --git a/backend/storage/src/sandbox-starters/node/index.js b/backend/storage/src/sandbox-starters/node/index.js
deleted file mode 100644
index a420803..0000000
--- a/backend/storage/src/sandbox-starters/node/index.js
+++ /dev/null
@@ -1 +0,0 @@
-console.log('Hello World!');
diff --git a/backend/storage/src/sandbox-starters/node/package.json b/backend/storage/src/sandbox-starters/node/package.json
deleted file mode 100644
index b16d2c7..0000000
--- a/backend/storage/src/sandbox-starters/node/package.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "nodejs",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "keywords": [],
- "author": "",
- "license": "ISC",
- "dependencies": {
- "@types/node": "^18.0.6"
- }
-}
diff --git a/backend/storage/src/sandbox-starters/react/index.html b/backend/storage/src/sandbox-starters/react/index.html
deleted file mode 100644
index 0c2cdb0..0000000
--- a/backend/storage/src/sandbox-starters/react/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
- React Starter Code
-
-
-
-
-
-
diff --git a/backend/storage/src/sandbox-starters/react/package.json b/backend/storage/src/sandbox-starters/react/package.json
deleted file mode 100644
index e608f06..0000000
--- a/backend/storage/src/sandbox-starters/react/package.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "react",
- "private": true,
- "version": "0.0.0",
- "type": "module",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
- "preview": "vite preview"
- },
- "dependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0"
- },
- "devDependencies": {
- "@types/react": "^18.2.66",
- "@types/react-dom": "^18.2.22",
- "@vitejs/plugin-react": "^4.2.1",
- "eslint": "^8.57.0",
- "eslint-plugin-react": "^7.34.1",
- "eslint-plugin-react-hooks": "^4.6.0",
- "eslint-plugin-react-refresh": "^0.4.6",
- "vite": "^5.2.0"
- }
-}
diff --git a/backend/storage/src/sandbox-starters/react/src/App.css b/backend/storage/src/sandbox-starters/react/src/App.css
deleted file mode 100644
index 16d9202..0000000
--- a/backend/storage/src/sandbox-starters/react/src/App.css
+++ /dev/null
@@ -1,23 +0,0 @@
-div {
- width: 100%;
- height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-}
-
-h1 {
- color: #fff;
- margin: 0;
-}
-
-p {
- color: #777;
- margin: 0;
-}
-
-button {
- padding: 8px 16px;
- margin-top: 16px;
-}
\ No newline at end of file
diff --git a/backend/storage/src/sandbox-starters/react/src/App.jsx b/backend/storage/src/sandbox-starters/react/src/App.jsx
deleted file mode 100644
index f588bc9..0000000
--- a/backend/storage/src/sandbox-starters/react/src/App.jsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import './App.css'
-import { useState } from 'react'
-
-function App() {
-
- const [count, setCount] = useState(0)
-
- return (
-
-
React Starter Code
-
- Edit App.jsx to get started.
-
-
-
- )
-}
-
-export default App
diff --git a/backend/storage/src/sandbox-starters/react/src/main.jsx b/backend/storage/src/sandbox-starters/react/src/main.jsx
deleted file mode 100644
index 51a8c58..0000000
--- a/backend/storage/src/sandbox-starters/react/src/main.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react'
-import ReactDOM from 'react-dom/client'
-import App from './App.jsx'
-
-ReactDOM.createRoot(document.getElementById('root')).render(
-
-
- ,
-)
diff --git a/backend/storage/src/sandbox-starters/react/vite.config.js b/backend/storage/src/sandbox-starters/react/vite.config.js
deleted file mode 100644
index 5a33944..0000000
--- a/backend/storage/src/sandbox-starters/react/vite.config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { defineConfig } from 'vite'
-import react from '@vitejs/plugin-react'
-
-// https://vitejs.dev/config/
-export default defineConfig({
- plugins: [react()],
-})
diff --git a/backend/storage/src/startercode.ts b/backend/storage/src/startercode.ts
index 11f5ead..337f5ab 100644
--- a/backend/storage/src/startercode.ts
+++ b/backend/storage/src/startercode.ts
@@ -17,6 +17,129 @@ const startercode = {
}`,
},
],
+ react: [
+ {
+ name: 'package.json',
+ body: `{
+ "name": "react",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
+ },
+ "devDependencies": {
+ "@types/react": "^18.2.66",
+ "@types/react-dom": "^18.2.22",
+ "@vitejs/plugin-react": "^4.2.1",
+ "eslint": "^8.57.0",
+ "eslint-plugin-react": "^7.34.1",
+ "eslint-plugin-react-hooks": "^4.6.0",
+ "eslint-plugin-react-refresh": "^0.4.6",
+ "vite": "^5.2.0"
+ }
+}`,
+ },
+ {
+ name: 'vite.config.js',
+ body: `import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [react()],
+})
+`,
+ },
+ {
+ name: 'index.html',
+ body: `
+
+
+
+
+
+ React Starter Code
+
+
+
+
+
+
+`,
+ },
+ {
+ name: 'src/App.css',
+ body: `div {
+ width: 100%;
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
+
+h1 {
+ color: #fff;
+ margin: 0;
+}
+
+p {
+ color: #777;
+ margin: 0;
+}
+
+button {
+ padding: 8px 16px;
+ margin-top: 16px;
+}`,
+ },
+ {
+ name: 'src/App.jsx',
+ body: `import './App.css'
+import { useState } from 'react'
+
+function App() {
+
+ const [count, setCount] = useState(0)
+
+ return (
+
+
React Starter Code
+
+ Edit App.jsx to get started.
+
+
+
+ )
+}
+
+export default App
+`,
+ },
+ {
+ name: 'src/main.jsx',
+ body: `import React from 'react'
+import ReactDOM from 'react-dom/client'
+import App from './App.jsx'
+
+ReactDOM.createRoot(document.getElementById('root')).render(
+
+
+ ,
+)
+`,
+ },
+ ],
};
export default startercode;