diff options
| author | Dhravya Shah <[email protected]> | 2025-03-12 00:51:33 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-03-12 00:51:33 -0700 |
| commit | 8af182abafd827c632da3dc8cdc59d4278ed97bd (patch) | |
| tree | 8aad1006cd4f54143cb57b4bbfa77ae1d029c4fc /apps/backend/src | |
| parent | auto generated openapi schema (diff) | |
| download | supermemory-8af182abafd827c632da3dc8cdc59d4278ed97bd.tar.xz supermemory-8af182abafd827c632da3dc8cdc59d4278ed97bd.zip | |
Minor cleanup and fix
Diffstat (limited to 'apps/backend/src')
| -rw-r--r-- | apps/backend/src/index.tsx | 4 | ||||
| -rw-r--r-- | apps/backend/src/routes/actions.ts | 14 | ||||
| -rw-r--r-- | apps/backend/src/routes/integrations.ts | 6 | ||||
| -rw-r--r-- | apps/backend/src/routes/memories.ts | 4 | ||||
| -rw-r--r-- | apps/backend/src/routes/spaces.ts | 6 | ||||
| -rw-r--r-- | apps/backend/src/routes/user.ts | 4 | ||||
| -rw-r--r-- | apps/backend/src/utils/extractor.ts | 3 |
7 files changed, 14 insertions, 27 deletions
diff --git a/apps/backend/src/index.tsx b/apps/backend/src/index.tsx index 1e61304d..9700502b 100644 --- a/apps/backend/src/index.tsx +++ b/apps/backend/src/index.tsx @@ -28,9 +28,7 @@ import { ConfigType, GeneralConfigType, rateLimiter } from "hono-rate-limiter"; // Create base Hono app first const honoApp = new Hono<{ Variables: Variables; Bindings: Env }>(); -const app = fromHono(honoApp, { - base: "", -}); +const app = fromHono(honoApp); // Add all middleware and routes app.use("*", timing()); diff --git a/apps/backend/src/routes/actions.ts b/apps/backend/src/routes/actions.ts index f26b46a5..dd9311ed 100644 --- a/apps/backend/src/routes/actions.ts +++ b/apps/backend/src/routes/actions.ts @@ -40,9 +40,7 @@ import { typeDecider } from "../utils/typeDecider"; import { isErr, Ok } from "../errors/results"; import { fromHono } from "chanfana"; -const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { - base: "", -}) +const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>()) .post( "/chat", zValidator( @@ -725,6 +723,10 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { z.object({ content: z.string().min(1, "Content cannot be empty"), spaces: z.array(z.string()).max(5).optional(), + id: z.string().optional(), + // any type of metadata. must be json serializable. + metadata: z.any().optional(), + images: z.array(z.string()).optional(), prefetched: z .object({ contentToVectorize: z.string(), @@ -739,7 +741,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { ), async (c) => { const body = c.req.valid("json"); - console.log("body", body); + const user = c.get("user"); if (!user) { @@ -764,7 +766,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { body.content = `https://${body.content}`; } - const uuid = randomId(); + const uuid = body.id ?? randomId(); const contentId = `add-${user.id}-${uuid}`; const db = database(c.env.HYPERDRIVE.connectionString); @@ -910,6 +912,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { contentHash: documentHash, raw: (body.prefetched ?? body.content) + "\n\n" + body.spaces?.join(" "), + metadata: body.metadata, }); await c.env.CONTENT_WORKFLOW.create({ @@ -1198,4 +1201,3 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { ); export default actions; -import { Context } from 'hono/jsx' diff --git a/apps/backend/src/routes/integrations.ts b/apps/backend/src/routes/integrations.ts index a76563d7..d6b5c9b8 100644 --- a/apps/backend/src/routes/integrations.ts +++ b/apps/backend/src/routes/integrations.ts @@ -8,11 +8,7 @@ import { database } from "@supermemory/db"; import { fromHono } from "chanfana"; const integrations = fromHono( - new Hono<{ Variables: Variables; Bindings: Env }>(), - { - base: "", - } -).get("/notion/import", async (c) => { + new Hono<{ Variables: Variables; Bindings: Env }>()).get("/notion/import", async (c) => { const user = c.get("user"); if (!user) { return c.json({ error: "Unauthorized" }, 401); diff --git a/apps/backend/src/routes/memories.ts b/apps/backend/src/routes/memories.ts index f895bcbf..f79da8ce 100644 --- a/apps/backend/src/routes/memories.ts +++ b/apps/backend/src/routes/memories.ts @@ -11,9 +11,7 @@ import { import { and, database, desc, eq, or, sql, isNull } from "@supermemory/db"; import { fromHono } from "chanfana"; -const memories = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { - base: "", -}) +const memories = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>()) .get( "/", zValidator( diff --git a/apps/backend/src/routes/spaces.ts b/apps/backend/src/routes/spaces.ts index c051217a..e004ce78 100644 --- a/apps/backend/src/routes/spaces.ts +++ b/apps/backend/src/routes/spaces.ts @@ -15,11 +15,7 @@ import { randomId } from "@supermemory/shared"; import { fromHono } from "chanfana"; const spacesRoute = fromHono( - new Hono<{ Variables: Variables; Bindings: Env }>(), - { - base: "", - } -) + new Hono<{ Variables: Variables; Bindings: Env }>()) .get("/", async (c) => { const user = c.get("user"); if (!user) { diff --git a/apps/backend/src/routes/user.ts b/apps/backend/src/routes/user.ts index 761b2fa4..4905989f 100644 --- a/apps/backend/src/routes/user.ts +++ b/apps/backend/src/routes/user.ts @@ -13,9 +13,7 @@ import { DurableObjectStore } from "@hono-rate-limiter/cloudflare"; import { rateLimiter } from "hono-rate-limiter"; import { fromHono } from "chanfana"; -const user = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), { - base: "", -}) +const user = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>()) .get("/", (c) => { return c.json(c.get("user")); }) diff --git a/apps/backend/src/utils/extractor.ts b/apps/backend/src/utils/extractor.ts index 9bf76181..f033f8e1 100644 --- a/apps/backend/src/utils/extractor.ts +++ b/apps/backend/src/utils/extractor.ts @@ -1,8 +1,7 @@ import { Env } from "../types"; export const extractPageContent = async (content: string, env: Env) => { - console.log("content", content); - const resp = await fetch(`https://md.dhr.wtf?url=${content}`); + const resp = await fetch(`https://r.jina.ai/${content}`); if (!resp.ok) { throw new Error( |