Skip to content

feat: export compression constants and auto-wrap ModuleRef#55

Merged
VikramAditya33 merged 1 commit into
mainfrom
feat/export-constants-and-auto-wrap-moduleref
Apr 28, 2026
Merged

feat: export compression constants and auto-wrap ModuleRef#55
VikramAditya33 merged 1 commit into
mainfrom
feat/export-constants-and-auto-wrap-moduleref

Conversation

@VikramAditya33
Copy link
Copy Markdown
Collaborator

@VikramAditya33 VikramAditya33 commented Apr 28, 2026

Improves developer experience by exporting WebSocket compression constants and auto-wrapping NestJS ModuleRef for dependency injection.

Changes

Compression Constants Export: (Fixes #53)

  • Created constants.ts exporting all compression/decompression constants and App/SSLApp functions
  • Updated index.ts to export constants
  • Updated all documentation to use imports from uwestjs instead of uWebSockets.js
  • Updated examples in README.md, Adapter.md.

ModuleRef Auto-Wrapping: (Fixes #54)

  • Updated UwsAdapter constructor to auto-detect and wrap NestJS ModuleRef
  • Modified UwsAdapterOptions type to accept both ModuleRef types
  • Updated documentation to show simplified usage pattern
  • Added comprehensive tests for auto-wrapping behavior using it.each

All changes are backward compatible. Users can still manually wrap ModuleRef if preferred.

Summary by CodeRabbit

  • New Features

    • WebSocket compression configuration constants and app factory functions are now available for direct import from the module.
    • Adapter now accepts both custom and NestJS ModuleRef implementations.
  • Documentation

    • Updated WebSocket configuration examples and guidance with new import paths and options.
  • Tests

    • Added test coverage for moduleRef handling in various input scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59423454-e53d-455e-9929-a19e0e027adc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/export-constants-and-auto-wrap-moduleref

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

uWestJS Benchmark Results

Scenario Express req/s Fastify req/s uWestJS req/s Express throughput Fastify throughput uWestJS throughput uWestJS vs Express uWestJS vs Fastify
headers 13.86k 20.45k 47.18k 2.58 MB/s 3.82 MB/s 7.42 MB/s 3.40x 2.31x
hello-world 14.80k 25.07k 75.15k 2.46 MB/s 4.21 MB/s 7.45 MB/s 5.08x 3.00x
json-response 13.69k 20.74k 41.52k 3.74 MB/s 5.68 MB/s 10.14 MB/s 3.03x 2.00x
mixed-response 13.25k 19.66k 44.75k 3.06 MB/s 4.56 MB/s 9.05 MB/s 3.38x 2.28x
post-json 12.96k 11.83k 23.73k 2.40 MB/s 3.23 MB/s 4.03 MB/s 1.83x 2.01x
query-params 11.87k 19.10k 48.19k 2.61 MB/s 4.23 MB/s 6.48 MB/s 4.06x 2.52x
route-params 13.86k 20.29k 41.80k 3.16 MB/s 4.64 MB/s 8.33 MB/s 3.02x 2.06x
static-file 15.87k 21.61k 44.34k 157.52 MB/s 214.16 MB/s 438.77 MB/s 2.79x 2.05x

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/websocket/adapter/uws.adapter.ts`:
- Around line 172-179: The code should normalize explicit nulls from
options?.moduleRef to undefined before constructing HandlerExecutor so the "no
DI container" path is always represented consistently; update the flow around
the moduleRef variable (originating from options?.moduleRef) so that if
moduleRef === null it is set to undefined, then keep the existing check that
wraps NestJS ModuleRef via NestJsModuleRef.create(moduleRef as unknown as
NestModuleRef) when needed, and finally pass the normalized moduleRef (never
null) into new HandlerExecutor({ moduleRef }).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d8e11d6-0061-403b-a0a8-8ca799f9b38c

📥 Commits

Reviewing files that changed from the base of the PR and between 10db64a and 5ebfbfd.

📒 Files selected for processing (8)
  • README.md
  • docs/websocket/Adapter.md
  • docs/websocket/Middleware.md
  • src/websocket/adapter/uws.adapter.spec.ts
  • src/websocket/adapter/uws.adapter.ts
  • src/websocket/constants.ts
  • src/websocket/index.ts
  • src/websocket/interfaces/uws-options.interface.ts

Comment thread src/websocket/adapter/uws.adapter.ts
- Export WebSocket compression constants (SHARED_COMPRESSOR, DISABLED, etc.) and App/SSLApp functions from uwestjs
- Add auto-wrapping for NestJS ModuleRef to simplify DI setup
- Update all documentation to use uwestjs imports instead of uWebSockets.js
- Add comprehensive tests for ModuleRef auto-wrapping behavior
@VikramAditya33 VikramAditya33 force-pushed the feat/export-constants-and-auto-wrap-moduleref branch from 5ebfbfd to dbd1091 Compare April 28, 2026 02:25
@VikramAditya33 VikramAditya33 merged commit 2a58709 into main Apr 28, 2026
4 checks passed
@VikramAditya33 VikramAditya33 deleted the feat/export-constants-and-auto-wrap-moduleref branch April 28, 2026 02:59
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.

Simplify ModuleRef usage for dependency injection Export WebSocket compression constants from uwestjs

1 participant