link-stack/apps/bridge-frontend/app/_lib/routing.ts

18 lines
656 B
TypeScript
Raw Normal View History

2024-03-16 19:39:20 +01:00
import { NextRequest, NextResponse } from "next/server";
2024-04-29 17:27:25 +02:00
import { getService } from "./utils";
2024-03-16 19:39:20 +01:00
2024-04-29 17:27:25 +02:00
const notFound = () => new NextResponse(null, { status: 404 });
2024-03-16 19:39:20 +01:00
export const getOneBot = async (req: NextRequest): Promise<NextResponse> =>
2024-04-29 17:27:25 +02:00
notFound();
2024-03-16 19:39:20 +01:00
export const sendMessage = async (req: NextRequest): Promise<NextResponse> =>
2024-04-29 17:27:25 +02:00
getService(req)?.sendMessage(req) ?? notFound();
2024-03-16 19:39:20 +01:00
export const receiveMessages = async (
req: NextRequest,
2024-04-29 17:27:25 +02:00
): Promise<NextResponse> => getService(req)?.receiveMessages(req) ?? notFound();
2024-04-21 08:11:24 +02:00
export const handleWebhook = async (req: NextRequest): Promise<NextResponse> =>
2024-04-29 17:27:25 +02:00
getService(req)?.handleWebhook(req) ?? notFound();