Metamigo -> Bridge

This commit is contained in:
Darren Clarke 2024-04-21 09:44:30 +02:00
parent 242f3cf6b8
commit a445762a37
145 changed files with 396 additions and 16668 deletions

View file

@ -1,50 +0,0 @@
import { NextRequest, NextResponse } from "next/server";
import { Service } from "./service";
import { Facebook } from "./facebook";
const services: Record<string, Service> = {
facebook: Facebook,
none: NextResponse.error() as any,
};
const getService = (req: NextRequest): Service => {
const service = req.nextUrl.searchParams.get("service") ?? "none";
return services[service];
};
export const getAllBots = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.getAllBots(req);
export const getOneBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.getOneBot(req);
export const sendMessage = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.sendMessage(req);
export const receiveMessages = async (
req: NextRequest,
): Promise<NextResponse> => getService(req)?.receiveMessages(req);
export const registerBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.registerBot(req);
export const resetBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.resetBot(req);
export const requestCode = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.requestCode(req);
export const unverifyBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.unverifyBot(req);
export const refreshBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.refreshBot(req);
export const createBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.createBot(req);
export const deleteBot = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.deleteBot(req);
export const handleWebhook = async (req: NextRequest): Promise<NextResponse> =>
getService(req)?.handleWebhook(req);