You are browsing as a guest. Sign up (or log in) to start making projects!

2h 56m 52s logged

Realtime Socket.io + Express backend

  • Finally added a backend to Codeliver! I’m using the WebSocket node library Socket.io to handle realtime events and messaging, so I had to set up an Express server to handle the different requests and events
  • The backend also has to access the auth user data and the shared Prisma Postgres database, so it took me a while to make both the Next.js frontend and Express backend to be able to read and write to it properly (since they are technically their own repos)
  • Also implemented Socket.io client to the Next.js frontend so whenever you send a message it either creates a new Chat object and sends the message or finds an existing one and adds a new message
  • Added Prisma schema and frontend types for chats, messages, and reactions
  • Added persistent message storing for each chat channel and removed the placeholder messages
  • Figured out how to send a Better Auth JWT token from the frontend and verify the session on the backend to authorize messaging features
  • I had to deal with a lot of annoying CORS, environment variable, and auth stuff, so that was not fun but the result was worth it
0
4

Comments 0

No comments yet. Be the first!