mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-08 22:21:07 +00:00
delete route
This commit is contained in:
parent
126b2d00df
commit
1bd71de749
1 changed files with 27 additions and 0 deletions
27
apps/cf-ai-backend/src/routes/delete.ts
Normal file
27
apps/cf-ai-backend/src/routes/delete.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { Request } from '@cloudflare/workers-types';
|
||||
import { type CloudflareVectorizeStore } from '@langchain/cloudflare';
|
||||
import { OpenAIEmbeddings } from '../OpenAIEmbedder';
|
||||
import { GenerativeModel } from '@google/generative-ai';
|
||||
import { seededRandom } from '../util';
|
||||
|
||||
export async function DELETE(request: Request, store: CloudflareVectorizeStore, _: OpenAIEmbeddings, m: GenerativeModel, env: Env) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const websiteUrl = searchParams.get('websiteUrl');
|
||||
const user = searchParams.get('user');
|
||||
|
||||
if (!websiteUrl || !user) {
|
||||
return new Response(JSON.stringify({ message: 'Invalid Request, need websiteUrl and user' }), { status: 400 });
|
||||
}
|
||||
|
||||
const ourID = `${websiteUrl}-${user}`;
|
||||
|
||||
const uuid = await env.KV.get(ourID);
|
||||
|
||||
if (!uuid) {
|
||||
return new Response(JSON.stringify({ message: 'Document not found' }), { status: 404 });
|
||||
}
|
||||
|
||||
await store.delete({ ids: [uuid] });
|
||||
|
||||
return new Response(JSON.stringify({ message: 'Document deleted' }), { status: 200 });
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue