This commit is contained in:
bipproduction
2025-10-20 17:30:08 +08:00
parent cc9d5480fa
commit e025dc3258
19 changed files with 1421 additions and 4242 deletions

View File

@@ -1,14 +1,12 @@
import Elysia, { t } from "elysia";
import { prisma } from "../lib/prisma";
const VERIFY_TOKEN = "token_yang_kamu_set_di_dashboard";
const WaHookRoute = new Elysia({
prefix: "/wa-hook",
tags: ["WhatsApp Hook"],
})
// ✅ Handle verifikasi Webhook (GET)
.get("/hook", async(ctx) => {
.get("/hook", async (ctx) => {
const { query, set } = ctx;
const mode = query["hub.mode"];
const challenge = query["hub.challenge"];
@@ -50,6 +48,12 @@ const WaHookRoute = new Elysia({
.post("/hook", async ({ body }) => {
console.log("Incoming WhatsApp Webhook:", body);
await prisma.waHook.create({
data: {
data: body,
},
});
return {
success: true,
message: "WhatsApp Hook received"
@@ -60,6 +64,17 @@ const WaHookRoute = new Elysia({
summary: "Receive WhatsApp Messages",
description: "Menerima pesan dari WhatsApp Webhook"
}
})
.get("/list-wahook", async () => {
const list = await prisma.waHook.findMany();
return {
list,
};
}, {
detail: {
summary: "List WhatsApp Hook",
description: "List semua WhatsApp Hook",
}
});
export default WaHookRoute;