16 lines
560 B
TypeScript
16 lines
560 B
TypeScript
import type { OutgoingMessage, WebhookRequestContext, WebhookResponse } from "./types.js";
|
|
|
|
export interface PlatformAdapter {
|
|
name: string;
|
|
handleWebhook(context: WebhookRequestContext): Promise<WebhookResponse>;
|
|
sendMessage(message: OutgoingMessage): Promise<void>;
|
|
}
|
|
|
|
export function jsonResponse(body: unknown, status = 200): WebhookResponse {
|
|
return { status, body };
|
|
}
|
|
|
|
export function notImplemented(platform: string): WebhookResponse {
|
|
return jsonResponse({ ok: false, error: `${platform} inbound webhook is not implemented in v1` }, 501);
|
|
}
|