feat(hail-recon): Hail Recon integration — storm intel panel, hail history, auto storm mode, address monitoring
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Receives POST from Hail Recon when a monitored address is hailed.
|
||||
* Stores the storm event in Vercel KV so /api/hail-status can serve it.
|
||||
*
|
||||
* Configure in Hail Recon dashboard:
|
||||
* Webhook URL: https://yourapp.vercel.app/api/hail-webhook?secret=YOUR_WEBHOOK_SECRET
|
||||
*/
|
||||
|
||||
import { kv } from '@vercel/kv';
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method !== 'POST') {
|
||||
return res.status(405).json({ error: 'Method not allowed' });
|
||||
}
|
||||
|
||||
const secret = process.env.HAIL_RECON_WEBHOOK_SECRET;
|
||||
if (secret && req.query.secret !== secret) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const payload = req.body || {};
|
||||
|
||||
const stormEvent = {
|
||||
address: payload.address || payload.street || 'Unknown address',
|
||||
city: payload.city || '',
|
||||
state: payload.state || 'TX',
|
||||
zip: payload.zip || '',
|
||||
hailSize: payload.hailSize || payload.hail_size || payload.size || null,
|
||||
stormDate: payload.stormDate || payload.storm_date || payload.date || new Date().toISOString(),
|
||||
markerId: payload.markerId || payload.AddressMarker_id || null,
|
||||
receivedAt: Date.now(),
|
||||
};
|
||||
|
||||
await kv.set('lastStormEvent', stormEvent);
|
||||
|
||||
console.log('[hail-webhook] Storm event stored:', stormEvent);
|
||||
|
||||
return res.status(200).json({ ok: true, received: stormEvent });
|
||||
}
|
||||
Reference in New Issue
Block a user