MCPcopy Create free account
hub / github.com/Dhravya/notty / extractContentJson

Method extractContentJson

src/durable-objects/user-notes.ts:1020–1030  ·  view source on GitHub ↗
(noteId: string)

Source from the content-addressed store, hash-verified

1018 this.sql.exec(
1019 `INSERT INTO media (id, type, filename, r2_key, mime_type, size, width, height) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
1020 body.id, body.type, body.filename, body.r2_key, body.mime_type, body.size, body.width ?? null, body.height ?? null
1021 );
1022 const rows = this.sql.exec("SELECT * FROM media WHERE id = ?", body.id).toArray();
1023 this.broadcastJson({ type: "media-added", media: rows[0] });
1024 return Response.json(rows[0]);
1025 }
1026 if (request.method === "DELETE" && path.startsWith("/media/")) {
1027 const id = path.slice("/media/".length);
1028 const rows = this.sql.exec("SELECT r2_key FROM media WHERE id = ?", id).toArray();
1029 this.sql.exec("DELETE FROM media WHERE id = ?", id);
1030 this.broadcastJson({ type: "media-deleted", id });
1031 return Response.json({ ok: true, r2_key: rows[0]?.r2_key });
1032 }
1033 if (request.method === "PATCH" && path.match(/^\/media\/[^/]+\/published$/)) {

Callers 2

getYDocMethod · 0.95
fetchMethod · 0.95

Calls 1

getYDocMethod · 0.95

Tested by

no test coverage detected