Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d149399
feat: server fanout + redis pub/sub
Rubinskiy Dec 31, 2025
acf90e1
Merge pull request #3 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
95e67fd
fix: push-images.yml change build context
Rubinskiy Jan 2, 2026
be4ab3e
Merge pull request #4 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
d2afcd8
fix: public folder change
Rubinskiy Jan 2, 2026
bff9fd1
Merge pull request #5 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
3068b24
fix: directories for build context
Rubinskiy Jan 2, 2026
c417a8e
Merge pull request #6 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
8f4c0c6
fix: directories for build context 2
Rubinskiy Jan 2, 2026
650aca3
Merge pull request #7 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
922d707
fix: package.json update
Rubinskiy Jan 2, 2026
2f2157d
Merge pull request #8 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 2, 2026
4e89be1
fix: public directory correction
Rubinskiy Jan 3, 2026
c675d34
Merge pull request #9 from join-a-groupchat/2-server-fanout-feature-w…
Rubinskiy Jan 3, 2026
8243e82
feat: unit tests
Rubinskiy Jan 17, 2026
ccd16be
fix: safety mechanism for pseudorandom
Rubinskiy Jan 17, 2026
135c3ca
fix: sonarqube sources
Rubinskiy Jan 17, 2026
ddb7d50
fix: sonarqube duplicate code exclusions
Rubinskiy Jan 17, 2026
463cbec
fix: sonarqube analysis
Rubinskiy Jan 17, 2026
9c8d5b6
fix: ES Lint & Unit Test directories
Rubinskiy Jan 17, 2026
9c30be7
fix: workflow directory
Rubinskiy Jan 17, 2026
4258006
fix: unit test workflow fix
Rubinskiy Jan 17, 2026
135d928
fix: unit test workflow fix 2
Rubinskiy Jan 17, 2026
0f683c3
fix: unit test workflow fix 3
Rubinskiy Jan 17, 2026
adf5889
fix: unit tests for server
Rubinskiy Jan 17, 2026
23f27d0
fix: fixed workflow unit tests
Rubinskiy Jan 17, 2026
c91be35
fix: added dotenv
Rubinskiy Jan 17, 2026
86956f0
fix: added sonar organization key
Rubinskiy Jan 17, 2026
ba6ebe1
fix: passed key to sonarscanner
Rubinskiy Jan 17, 2026
67a9e99
fix: updated readme
Rubinskiy Jan 17, 2026
592d753
fix: added coverage paths
Rubinskiy Jan 17, 2026
036d533
fix: sonar project key
Rubinskiy Jan 17, 2026
6632ec3
fix: sonarqube high-medium blockers
Rubinskiy Jan 17, 2026
183fc71
fix: unit test invalid number
Rubinskiy Jan 17, 2026
c328824
fix: code coverage in tests
Rubinskiy Jan 17, 2026
d594ee2
fix: workflow order
Rubinskiy Jan 17, 2026
ee3914e
fix: workflow modification
Rubinskiy Jan 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ npm-debug.log
# Environment files
.env
.env.local
.env.*.local
.env.prod
config

# Git
.git
Expand Down Expand Up @@ -37,3 +38,6 @@ docker-compose*.yml
dist
build

# ignore tests
tests
coverage
8 changes: 5 additions & 3 deletions .github/workflows/push-images.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Build and push images to GHCR

on:
workflow_dispatch:
push:
branches:
- main
Comment thread
Rubinskiy marked this conversation as resolved.

Comment on lines +4 to 7
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed workflow trigger from workflow_dispatch to automatic push on main branch. This will trigger builds on every push to main, which may increase CI costs and could deploy untested changes. Consider adding a manual approval step or keeping workflow_dispatch for production deployments.

Suggested change
push:
branches:
- main
workflow_dispatch:

Copilot uses AI. Check for mistakes.
permissions:
contents: read
Expand All @@ -24,11 +26,11 @@ jobs:
- name: Build & push server image
run: |
IMAGE=ghcr.io/rubinskiy/server:latest
docker build -t $IMAGE -f Dockerfile.server .
docker build -t $IMAGE -f server/Dockerfile.server .
docker push $IMAGE

- name: Build & push consumer image
run: |
IMAGE=ghcr.io/rubinskiy/consumer:latest
docker build -t $IMAGE -f Dockerfile.consumer .
docker build -t $IMAGE -f consumer/Dockerfile.consumer .
docker push $IMAGE

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Unit Tests for Server

on:
pull_request:
branches:
- staging
paths:
- 'server/**'
push:
branches:
- staging

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install server dependencies
run: npm install --ignore-scripts
working-directory: server

- name: Run Unit Tests & Generate Coverage
run: npm run test:unit -- --coverage
working-directory: server
env:
NODE_ENV: test
REDIS_PWD: ${{ secrets.REDIS_PWD }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
SUPABASE_DB_URL: ${{ secrets.SUPABASE_DB_URL }}

- name: Upload coverage reports
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a commit SHA for action version is good practice, but consider adding a comment indicating which version tag this corresponds to for maintainability.

Suggested change
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # codecov-action v4.4.1

Copilot uses AI. Check for mistakes.
with:
directory: server/coverage
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install --ignore-scripts
working-directory: server

- name: Run ESLint
run: npx eslint server --ext .js
continue-on-error: true
40 changes: 40 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: SonarQube Scan

on:
workflow_run:
workflows: ["Unit Tests for Server"]
types:
- completed

jobs:
scan:
runs-on: ubuntu-latest
environment: analysis

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install --ignore-scripts

# Optional: run tests to generate coverage file
#- name: Run tests
# run: npm test -- --coverage

- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@v2
with:
projectBaseDir: server
args: >
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
14 changes: 0 additions & 14 deletions Dockerfile.consumer

This file was deleted.

15 changes: 0 additions & 15 deletions Dockerfile.server

This file was deleted.

56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# prototype-rtc-js
Real -time scalable group chat app with uWebSockets, Redis, and Postgres

### How to run (Local) >>

Using code?
```bash
node server.js

node consumer.js
```
Also run local redis instance.
```bash
docker start redis-local
```
Also run local Postgres instance.
```bash
docker start local-pg
```
Don't forget to change env variables to local redis and pg
```bash
SUPABASE_DB_URL=postgres://postgres:postgres@localhost:5432/messages
```

Using containers to run server?
```bash
docker build -t server-local -f Dockerfile.server .

docker run --env-file .env-local -p 9001:9001 server-local
```
Run local redis instance too.

### How to run (PM2 Multiple Instances) >>

```bash
pm2 start server.js -i <instance-num>
```

Also run local redis instance.
Change local vars to local redis host and port.

Check logs
```bash
pm2 logs
```

Stop all instances
```bash
pm2 stop all
```

### Testing >>

Server Unit Tests
```bash
cd server
npm run test:unit
```
5 changes: 5 additions & 0 deletions .env.example → config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ SUPABASE_DB_URL=
REDIS_PWD=
REDIS_HOST=
REDIS_PORT=

# TESTS
TOTAL_MESSAGES=
BATCH_SIZE=
CONCURRENCY=
78 changes: 0 additions & 78 deletions consumer.js

This file was deleted.

19 changes: 19 additions & 0 deletions consumer/Dockerfile.consumer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dockerfile.consumer
FROM node:20-alpine

WORKDIR /app

# Install only production dependencies
COPY package*.json ./
RUN npm ci --only=production

# Copy consumer modular codebase structure
COPY consumer/ ./consumer/

# Copy config directory (for .env file structure)
# Note: .env file should be provided via environment variables in production
# The config directory should exist in the repo (even if empty)
COPY config/ ./config/

# Small health-check-friendly default command
CMD ["node", "consumer/consumer.js"]
Loading
Loading