remove kv

This commit is contained in:
Ishaan Dey 2024-05-26 18:45:28 -07:00
parent 6376493ae7
commit ae15e44472
2 changed files with 2 additions and 32 deletions

View File

@ -23,7 +23,7 @@ npm run dev
### Backend ### Backend
The backend consists of a primary Express and Socket.io server, and 3 Cloudflare Workers microservices for the D1 database, R2 storage, and Workers AI. The D1 database also serves as a KV store for user sessions, and it contains a [service binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/) to the R2 storage worker. The backend consists of a primary Express and Socket.io server, and 3 Cloudflare Workers microservices for the D1 database, R2 storage, and Workers AI. The D1 database also contains a [service binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/) to the R2 storage worker.
#### Socket.io server #### Socket.io server
@ -145,7 +145,6 @@ It should be in the form `category(scope or module): message` in your commit mes
- [D1 database](https://developers.cloudflare.com/d1/) - [D1 database](https://developers.cloudflare.com/d1/)
- [R2 storage](https://developers.cloudflare.com/r2/) - [R2 storage](https://developers.cloudflare.com/r2/)
- [Workers AI](https://developers.cloudflare.com/workers-ai/) - [Workers AI](https://developers.cloudflare.com/workers-ai/)
- [Workers KV](https://developers.cloudflare.com/kv/)
- [Express](https://expressjs.com/) - [Express](https://expressjs.com/)
- [Socket.io](https://socket.io/) - [Socket.io](https://socket.io/)
- [Drizzle ORM](https://orm.drizzle.team/) - [Drizzle ORM](https://orm.drizzle.team/)

View File

@ -10,7 +10,6 @@ import { and, eq, sql } from "drizzle-orm"
export interface Env { export interface Env {
DB: D1Database DB: D1Database
STORAGE: any STORAGE: any
KV: KVNamespace
KEY: string KEY: string
STORAGE_WORKER_URL: string STORAGE_WORKER_URL: string
} }
@ -41,35 +40,7 @@ export default {
const db = drizzle(env.DB, { schema }) const db = drizzle(env.DB, { schema })
if (path === "/api/session") { if (path === "/api/sandbox") {
if (method === "PUT") {
const body = await request.json()
const schema = z.object({
userId: z.string(),
sandboxId: z.string(),
})
const { userId, sandboxId } = schema.parse(body)
await env.KV.put(userId, sandboxId)
return success
} else if (method === "GET") {
const params = url.searchParams
if (params.has("id")) {
const id = params.get("id") as string
const sandboxId = await env.KV.get(id)
return json({ sandboxId })
} else return invalidRequest
} else if (method === "DELETE") {
const params = url.searchParams
if (params.has("id")) {
const id = params.get("id") as string
await env.KV.delete(id)
return success
} else return invalidRequest
} else return methodNotAllowed
} else if (path === "/api/sandbox") {
if (method === "GET") { if (method === "GET") {
const params = url.searchParams const params = url.searchParams
if (params.has("id")) { if (params.has("id")) {