Skip to content

Commit

Permalink
Handle ping POST requests and Websocket pings
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelpapineau committed Sep 27, 2023
1 parent eaf9689 commit 4c94586
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ Bun.serve<{key: string}>({
if (!isVerified) return new Response("invalid request signature", { status: 401 });

// publish message to subscribers
console.log(JSON.parse(body))

if (JSON.parse(body).message == "PING"){
const message = JSON.parse(body).message;
const response = server.publish(message, body);
console.log('server.publish', {response, message});
return new Response("OK");
}
const { clock, manifest } = JSON.parse(body);
const { moduleHash } = manifest;
moduleHashes.add(moduleHash);
Expand Down
2 changes: 1 addition & 1 deletion src/sqlite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function create(db){
function create(db: any){
db.query(`create table if not exists data (moduleHash text primary key)`).run();
}

Expand Down

0 comments on commit 4c94586

Please sign in to comment.