Skip to content

Express + Postgress demo for live match commentary with a WebScoket broadcast channel. Focus is on WS patterns (heartbeats, backpressure, message validation, subscriptions).

License

Notifications You must be signed in to change notification settings

shahyash1136/websocketWithLiveScoreApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websocketWithLiveScoreApp

Monorepo with two Node.js projects:

  • sportz: Express + WebSocket live score API with PostgreSQL via Drizzle ORM.
  • websockets: Minimal WebSocket broadcast server for quick testing.

Repo Layout

  • sportz/ - main live score app
  • websockets/ - lightweight WS playground
  • README.md - this file

sportz

What It Does

  • REST API for matches and commentary
  • WebSocket server that broadcasts live commentary updates

Quick Start

cd sportz
npm install
npm run dev

Server logs:

Server is running on http://localhost:8000
WebSocket Server is running on ws://localhost:8000/ws

Environment

Set DATABASE_URL in sportz/.env:

DATABASE_URL=postgres://user:pass@localhost:5432/dbname

REST Endpoints

  • GET /matches
  • POST /matches
  • GET /matches/:matchId/commentary
  • POST /matches/:matchId/commentary

WebSocket

Connect to:

ws://localhost:8000/ws

Subscribe:

{"type":"subscribe","matchId":1}

Unsubscribe:

{"type":"unsubscribe","matchId":1}

Broadcasts:

{"type":"commentary","data":{...}}
{"type":"match_created","data":{...}}

websockets

Quick Start

cd websockets
npm install
npm run dev

Server logs:

Webscoket server is live on ws://localhost:8080

Try It From The CLI

npx wscat -c ws://localhost:8080

Type a message and hit enter to broadcast to all clients.

Notes

  • Both projects use node --watch for development.
  • The sportz app is the primary service; websockets is a simple playground.

About

Express + Postgress demo for live match commentary with a WebScoket broadcast channel. Focus is on WS patterns (heartbeats, backpressure, message validation, subscriptions).

Topics

Resources

License

Stars

Watchers

Forks