Skip to content

Instantly share code, notes, and snippets.

@avneesh0612
Created July 18, 2024 16:57
Show Gist options
  • Save avneesh0612/9fa31cdbb5aa86c46cdb1d50deef9001 to your computer and use it in GitHub Desktop.
Save avneesh0612/9fa31cdbb5aa86c46cdb1d50deef9001 to your computer and use it in GitHub Desktop.
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