GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - NeaByteLab/SSE-Server: Demonstrates Server-Sent Events (SSE) server implementation with real-time HTTP request monitoring dashboard.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.js
eslint.config.js
 
 
index.html
index.html
 
 
package.json
package.json
 
 
preview.gif
preview.gif
 
 
run.sh
run.sh
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

SSE Server

A Server-Sent Events (SSE) monitoring tool that creates a real-time HTTP request monitoring dashboard. This project demonstrates how to build an SSE server and integrate it with the @neabyte/sse-client library.

SSE Server Demo

📦 Installation

# Clone the repository
git clone https://github.com/NeaByteLab/SSE-Server.git
cd SSE-Server

# Install dependencies
npm install

# Start the server
npm start

🎯 Quick Start

  1. Start the SSE Server:

    npm start

    Server will run on http://localhost:3000

  2. Open the Dashboard: Navigate to http://localhost:3000 in your browser

  3. Send Test Requests:

    # Run the test script
    ./run.sh
    
    # Or send individual requests
    curl -X POST http://localhost:3000/api/test -H "Content-Type: application/json" -d '{"test": "data"}'
  4. Watch Real-time Updates: Requests will appear instantly in the dashboard with full details


🏗️ Architecture

Server-Side (src/index.ts)

// EventEmitter for managing SSE connections
const eventEmitter: EventEmitter = new EventEmitter()
const clientConnections: ServerResponse[] = []

// SSE endpoint handler
if (req.url === '/sse') {
  res.writeHead(200, {
    'Content-Type': 'text/event-stream',
    'Cache-Control': 'no-cache',
    Connection: 'keep-alive'
  })
  clientConnections.push(res)
  res.write('data: Connected\n\n')
}

// HTTP request capture and broadcast
eventEmitter.emit('http-request', {
  method: req.method,
  url: req.url,
  headers: req.headers,
  body: body
})

Client-Side (index.html)

// Using @neabyte/sse-client CDN
import sseClient from 'https://cdn.jsdelivr.net/npm/@neabyte/sse-client/+esm'

// Configuration with auto-reconnection
const config = {
  retryInterval: 3000,    // Retry every 3 seconds
  retryAttempts: 5,       // Try up to 5 times
  autoReconnect: true,    // Enable auto-reconnection
  timeout: 30000          // 30 second connection timeout
}

// Create SSE client
const client = sseClient('/sse', (message) => {
  // Handle incoming messages
  if (message.event === 'http-request') {
    // Display request in UI
  }
}, config)

🔧 API Endpoints

Endpoint Method Description
/ GET Serves the monitoring dashboard
/sse GET SSE endpoint for real-time updates
/* ANY Captures all other requests and broadcasts them

📊 SSE Client Integration

This project demonstrates integration with the @neabyte/sse-client library:

CDN Usage

<script type="module">
  import sseClient from 'https://cdn.jsdelivr.net/npm/@neabyte/sse-client/+esm'

  const client = sseClient('/sse', (message) => {
    console.log('SSE Response:', message)
  })
</script>

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Demonstrates Server-Sent Events (SSE) server implementation with real-time HTTP request monitoring dashboard.

www.npmjs.org/package/@neabyte/sse-client

Topics

api-testingdashboarddevelopment-toolshttp-monitoringmonitoringnodejsreal-timeserver-sent-eventsssetypescriptwebsockets

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.