Skip to content

Commit

Permalink
log errors in workers
Browse files Browse the repository at this point in the history
  • Loading branch information
aabassiouni committed May 21, 2024
1 parent e9f8bc9 commit 5159fed
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions apps/workers/src/routes/#.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,36 @@ import { env } from "hono/adapter";
import { db } from "../db";

export async function #Route(c: Context) {
try {
const waitlist = c.req.param("waitlist");
const body = await c.req.json();
const email = body.email;
const waitlist = c.req.param("waitlist");
const body = await c.req.json();
const email = body.email;

const #ID = newId("su");
const _record = await db.insert(#s).values({
const #ID = newId("su");

const _record = await db
.insert(#s)
.values({
#ID,
waitlistID: waitlist,
email,
})
.catch((e) => {
console.log(e);
return c.json({ message: "Internal Server Error" }, { status: 500 });
});

await fetch(`${env(c).REALTIME_API_URL}/receive`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
waitlist_id: waitlist,
update: "update from workers",
}),
});
await fetch(`${env(c).REALTIME_API_URL}/receive`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
waitlist_id: waitlist,
update: "update from workers",
}),
}).catch((e) => {
console.log(e);
});

return c.json({ id: #ID, message: "# Successful" });
} catch {
return c.json({ message: "Internal Server Error" }, { status: 500 });
}
return c.json({ id: #ID, message: "# Successful" });
}

0 comments on commit 5159fed

Please # to comment.