Skip to content

Conversation

@KristjanESPERANTO
Copy link
Collaborator

This PR improves clientonly start option with better code structure, validation, and comprehensive test coverage.

Changes

Refactoring:

  • Improved parameter handling with explicit function parameter passing instead of closure
  • Added port validation (1-65535) with proper NaN handling
  • Removed unnecessary IIFE wrapper (Node.js modules are already scoped)
  • Extracted getCommandLineParameter as a reusable top-level function
  • Enhanced error reporting with better error messages
  • Added connection logging for debugging

Testing:

  • Added comprehensive e2e tests for parameter validation
  • Test coverage for missing/incomplete parameters
  • Test coverage for local address rejection (localhost, 127.0.0.1, ::1, ::ffff:127.0.0.1)
  • Test coverage for port validation (invalid ranges, non-numeric values)
  • Test coverage for TLS flag parsing
  • Integration test with running server

Testing

All tests pass:

npm test -- tests/e2e/clientonly_spec.js
# ✓ 18 tests passed

- Test missing/incomplete parameters (address, port)
- Test rejection of local addresses (localhost, 127.0.0.1, ::1, etc.)
- Test port validation (0, negative, >65535, non-numeric)
- Test --use-tls flag parsing
- Test server /config/ endpoint availability
- Remove IIFE (Node.js modules are already scoped)
- Extract getCommandLineParameter as top-level function
- Add connection logging for better debugging
@khassel
Copy link
Collaborator

khassel commented Jan 28, 2026

Not directly related to this pull request, but I've been wondering whether we need these subdirectories for clientonly and serveronly. We could put everything under js and simply change the call in package.json for serveronly. And we could do the same for clientonly.

But maybe I've overlooked something that argues against it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants