Skip to content

joocy/price-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Price Server

A lightweight Express server that streams simulated real-time stock price updates over Server-Sent Events (SSE).

What it does

Exposes a single endpoint GET /prices that:

  1. Immediately sends a snapshot of all 10 stock prices (AAPL, MSFT, GOOGL, AMZN, TSLA, META, NVDA, JPM, BAC, GS)
  2. Continuously streams random price updates — 1–4 symbols per tick, every 300–1500 ms

Each SSE message is a JSON array of { symbol, price } objects.

Install

pnpm install

Run

# Development (watch mode)
pnpm dev

# Production
pnpm start

The server listens on http://localhost:3000.

Usage

Connect any SSE client to http://localhost:3000/prices:

const source = new EventSource('http://localhost:3000/prices');
source.onmessage = ({ data }) => console.log(JSON.parse(data));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors