Files
spotlightcam/backend
Radosław Gierwiało 4a91a10aff feat(chat): add 2000 character limit for messages
Added message length validation to prevent spam and improve UX with
character counter feedback.

Backend:
- Added MESSAGE_MAX_LENGTH constant (2000 characters)
- Validation in send_event_message handler:
  - Check if content is string
  - Check if not empty after trim
  - Check if not exceeding max length
- Validation in send_match_message handler (same checks)
- Returns error message if validation fails

Frontend:
- Added MESSAGE_MAX_LENGTH constant (2000 characters)
- ChatInput component enhancements:
  - maxLength attribute on input (hard limit)
  - Character counter shows when >80% of limit
  - Counter turns red when at limit
  - Submit button disabled when at limit
  - Counter format: "X/2000"

UX:
- User sees counter at 1600+ characters (80% of limit)
- Hard limit prevents typing beyond 2000 chars
- Clear visual feedback (red text) when at limit
- Consistent validation on both event and match chats

Security:
- Prevents spam with extremely long messages
- Protects against potential DoS via message size
- Database already uses TEXT type (supports limit)
2025-12-02 23:46:54 +01:00
..

spotlight.cam Backend

Node.js + Express backend for spotlight.cam - P2P video exchange app for dance events.

Features

  • Express REST API
  • CORS enabled
  • Health check endpoint
  • Error handling
  • Unit tests (Jest + Supertest)
  • PostgreSQL integration (planned)
  • JWT authentication (planned)
  • Socket.IO for real-time chat (planned)
  • WebRTC signaling (planned)

API Endpoints

Health Check

  • GET /api/health - Backend health status

Future Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/users/me - Get current user
  • GET /api/events - List events
  • POST /api/matches - Create match
  • POST /api/ratings - Rate partner

Development

Install dependencies

npm install

Run in development mode

npm run dev

Run tests

npm test

Run tests in watch mode

npm run test:watch

Run in production mode

npm start

Environment Variables

Create a .env file (see .env.example):

NODE_ENV=development
PORT=3000
CORS_ORIGIN=http://localhost:8080

Project Structure

backend/
├── src/
│   ├── __tests__/          # Unit tests
│   │   └── app.test.js
│   ├── routes/             # API routes (future)
│   ├── controllers/        # Business logic (future)
│   ├── middleware/         # Custom middleware (future)
│   ├── utils/              # Helper functions (future)
│   ├── app.js              # Express app setup
│   └── server.js           # Server entry point
├── .env                    # Environment variables (gitignored)
├── .env.example            # Environment variables template
├── package.json
└── Dockerfile

Testing

Tests are written using:

  • Jest - Test framework
  • Supertest - HTTP assertions

Run tests:

npm test

Current test coverage:

  • Health check endpoint
  • 404 error handling
  • CORS configuration
  • JSON body parsing

Docker

Build and run with Docker Compose (from project root):

docker compose up --build

Backend will be available at:

Next Steps

  1. Basic Express setup
  2. Health check endpoint
  3. Unit tests
  4. PostgreSQL connection
  5. Database schema and migrations
  6. Authentication (JWT + bcrypt)
  7. Socket.IO for real-time chat
  8. WebRTC signaling

License

TBD