diff --git a/apps/messaging/src/index.ts b/apps/messaging/src/index.ts index e59feb2..e752d6b 100644 --- a/apps/messaging/src/index.ts +++ b/apps/messaging/src/index.ts @@ -1,10 +1,6 @@ import { swagger } from "@elysiajs/swagger"; import { Elysia } from "elysia"; -import { - handleGetMessages, - handleHealthCheck, - handleSendMessage, -} from "./routes"; +import { handleHealthCheck, handleSendMessage } from "./routes"; import { messageSchema } from "./types"; const PORT = process.env.PORT || 3000; @@ -75,81 +71,6 @@ const app = new Elysia() }, }, }) - .get("/api/messages/receive", handleGetMessages, { - detail: { - tags: ["messages"], - description: "Get received messages", - parameters: [ - { - in: "query", - name: "userId", - schema: { type: "string" }, - required: false, - }, - { - in: "query", - name: "limit", - schema: { type: "number" }, - required: false, - }, - { - in: "query", - name: "offset", - schema: { type: "number" }, - required: false, - }, - { - in: "query", - name: "platform", - schema: { - type: "string", - enum: ["whatsapp", "telegram", "simulator"], - }, - required: false, - }, - ], - responses: { - "200": { - description: "Messages retrieved successfully", - content: { - "application/json": { - schema: { - type: "object", - properties: { - messages: { - type: "array", - items: { - type: "object", - properties: { - id: { type: "string" }, - userId: { type: "string" }, - text: { type: "string" }, - platform: { type: "string" }, - timestamp: { type: "number" }, - }, - }, - }, - }, - }, - }, - }, - }, - "400": { - description: "Invalid request parameters", - content: { - "application/json": { - schema: { - type: "object", - properties: { - error: { type: "string" }, - }, - }, - }, - }, - }, - }, - }, - }) .get("/api/messages/health", handleHealthCheck, { detail: { tags: ["health"], diff --git a/apps/messaging/src/routes.ts b/apps/messaging/src/routes.ts index e8525ae..e006efd 100644 --- a/apps/messaging/src/routes.ts +++ b/apps/messaging/src/routes.ts @@ -63,48 +63,6 @@ export async function handleSendMessage(req: Request) { } } -export async function handleGetMessages(req: Request) { - try { - const url = new URL(req.url); - const params = queryParamsSchema.parse( - Object.fromEntries(url.searchParams), - ); - - let query = supabase - .from("received_messages") - .select("*") - .order("timestamp", { ascending: false }); - - if (params.userId) { - query = query.eq("user_id", params.userId); - } - if (params.limit) { - query = query.limit(params.limit); - } - if (params.offset) { - query = query.range( - params.offset, - params.offset + (params.limit || 10) - 1, - ); - } - if (params.platform) { - query = query.eq("meta->platform", params.platform); - } - - const { data, error } = await query; - - if (error) throw error; - - return Response.json({ messages: data }); - } catch (error) { - logger.error("Error fetching messages", { error }); - return Response.json( - { error: "Failed to fetch messages" }, - { status: 400 }, - ); - } -} - export function handleHealthCheck() { return Response.json({ status: "healthy" }); }