Skip to content

Instantly share code, notes, and snippets.

View prav-raghu's full-sized avatar
🐍
Working from home

Pravir Raghu prav-raghu

🐍
Working from home
View GitHub Profile
@prav-raghu
prav-raghu / fastify-server.ts
Created August 31, 2021 19:08
Fastify ws socket
// [the entire purpose of this exercise is to make a post request that will emit an event that takes in an id that should match up with one of the connected socket clients
// if we get this process right it will not only help with our payment work thats being worked on but any future dashboard realtime updates for stats]
// step processes work as follows with no auth considered in this code
// 1) make a post request with a unique identifier attached to it
// 2) if there exists a client with said matching unique identifier thats currently open accept that message from the server
// 3) we can choose in this case to then close the connection for that client
// ** lets assume this is what would done for the payment
// [feed back will be much appreciated]
'use strict';
import { v4 as uuidv4 } from "uuid";