remove kv
This commit is contained in:
parent
6376493ae7
commit
ae15e44472
@ -23,7 +23,7 @@ npm run dev
|
||||
|
||||
### 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
|
||||
|
||||
@ -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/)
|
||||
- [R2 storage](https://developers.cloudflare.com/r2/)
|
||||
- [Workers AI](https://developers.cloudflare.com/workers-ai/)
|
||||
- [Workers KV](https://developers.cloudflare.com/kv/)
|
||||
- [Express](https://expressjs.com/)
|
||||
- [Socket.io](https://socket.io/)
|
||||
- [Drizzle ORM](https://orm.drizzle.team/)
|
||||
|
@ -10,7 +10,6 @@ import { and, eq, sql } from "drizzle-orm"
|
||||
export interface Env {
|
||||
DB: D1Database
|
||||
STORAGE: any
|
||||
KV: KVNamespace
|
||||
KEY: string
|
||||
STORAGE_WORKER_URL: string
|
||||
}
|
||||
@ -41,35 +40,7 @@ export default {
|
||||
|
||||
const db = drizzle(env.DB, { schema })
|
||||
|
||||
if (path === "/api/session") {
|
||||
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 (path === "/api/sandbox") {
|
||||
if (method === "GET") {
|
||||
const params = url.searchParams
|
||||
if (params.has("id")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user