Prepare server deployment
This commit is contained in:
@ -8,7 +8,7 @@ export default async function TestPage({ searchParams }: { searchParams: Promise
|
||||
redirect('/login')
|
||||
}
|
||||
|
||||
const logs = readJsonFile<any[]>('webhook-logs.json', [])
|
||||
const logs = readJsonFile<unknown[]>('webhook-logs.json', [])
|
||||
const state = readJsonFile<Record<string, unknown>>('flow-state.json', {})
|
||||
const params = await searchParams
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ export default async function WebhookLogsPage() {
|
||||
redirect('/login')
|
||||
}
|
||||
|
||||
const logs = readJsonFile<any[]>('webhook-logs.json', [])
|
||||
const logs = readJsonFile<unknown[]>('webhook-logs.json', [])
|
||||
|
||||
return (
|
||||
<div className="wrap">
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
import { appendLog, readJsonFile, writeJsonFile } from './storage'
|
||||
|
||||
type FlowState = Record<string, { step: string; name?: string }>
|
||||
type WebhookValue = {
|
||||
messages?: IncomingMessage[]
|
||||
statuses?: unknown[]
|
||||
}
|
||||
type WebhookChange = {
|
||||
value?: WebhookValue
|
||||
}
|
||||
type WebhookEntry = {
|
||||
changes?: WebhookChange[]
|
||||
}
|
||||
type WebhookPayload = {
|
||||
entry?: WebhookEntry[]
|
||||
}
|
||||
type IncomingMessage = {
|
||||
from?: string
|
||||
text?: {
|
||||
body?: string
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeNumber(number?: string | null) {
|
||||
return (number || '').replace(/\D+/g, '')
|
||||
@ -37,7 +56,7 @@ export async function sendTextMessage(to: string, message: string) {
|
||||
return payload
|
||||
}
|
||||
|
||||
export async function handleWebhook(payload: any) {
|
||||
export async function handleWebhook(payload: WebhookPayload) {
|
||||
appendLog({ type: 'webhook_received', payload, created_at: new Date().toISOString() })
|
||||
|
||||
for (const entry of payload.entry || []) {
|
||||
@ -55,7 +74,7 @@ export async function handleWebhook(payload: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleIncomingMessage(message: any) {
|
||||
async function handleIncomingMessage(message: IncomingMessage) {
|
||||
const from = message.from || ''
|
||||
appendLog({ type: 'incoming_message', from, message, created_at: new Date().toISOString() })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user