-
-
Save avneesh0612/9fa31cdbb5aa86c46cdb1d50deef9001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { v4 as uuidv4 } from "uuid"; | |
const server = Bun.serve({ | |
port: 3000, | |
async fetch(req) { | |
try { | |
const info = await req.json(); | |
const DCreq = await fetch( | |
"https://api.warpcast.com/v2/ext-send-direct-cast", | |
{ | |
method: "PUT", | |
headers: { | |
Authorization: "Bearer <warpcast_api_key>", | |
"Content-Type": "application/json", | |
}, | |
body: JSON.stringify({ | |
recipientFid: info.data.author.fid, | |
message: "gm", | |
idempotencyKey: uuidv4(), | |
}), | |
} | |
); | |
const res = await DCreq.json(); | |
console.log(res); | |
return new Response("success!"); | |
} catch (e: any) { | |
console.error(e); | |
return new Response(e.message, { status: 500 }); | |
} | |
}, | |
}); | |
console.log(`Listening on localhost:${server.port}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment