Add global middleware and guard support#675
Merged
notaphplover merged 6 commits intomainfrom May 1, 2025
Merged
Conversation
…fyHttpAdapterErrorKind enum
…thods in InversifyHttpAdapter
|
Contributor
Benchmarks results:> root@ benchmarks:http:cjs /home/runner/work/monorepo/monorepo
> pnpm run --filter "@inversifyjs/http-benchmarks" benchmarks:run:cjs
> @inversifyjs/http-benchmarks@ benchmarks:run:cjs /home/runner/work/monorepo/monorepo/packages/http/tools/http-benchmarks
> BUILD_TARGET=cjs ./bin/run-cjs.cjs
[CJS] Running benchmarks...
Express Basic Get Request
┌─────────┬───────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼───────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyExpress' │ '112.878' │ '44.360' │ '3943.387' │ 43622 │
│ 1 │ 'express' │ '102.856' │ '43.936' │ '4356.461' │ 48148 │
│ 2 │ 'NestJSExpress' │ '113.005' │ '45.848' │ '3953.930' │ 43649 │
└─────────┴───────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyExpress vs express Speedup: 0.905x
currentInversifyExpress vs NestJSExpress Speedup: 0.997x
Express v4 Basic Get Request
┌─────────┬────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyExpress4' │ '100.731' │ '43.099' │ '4469.690' │ 49283 │
│ 1 │ 'express4' │ '97.542' │ '42.493' │ '4618.384' │ 50989 │
└─────────┴────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyExpress4 vs express4 Speedup: 0.968x
Fastify Basic Get Request
┌─────────┬───────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼───────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyFastify' │ '43.111' │ '38.149' │ '11641.916' │ 117652 │
│ 1 │ 'fastify' │ '34.203' │ '29.422' │ '14562.471' │ 146487 │
│ 2 │ 'NestJSFastify' │ '38.211' │ '33.385' │ '13242.147' │ 134241 │
└─────────┴───────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyFastify vs fastify Speedup: 0.799x
currentInversifyFastify vs NestJSFastify Speedup: 0.879x
Hono Basic Get Request
┌─────────┬────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyHono' │ '40.815' │ '36.361' │ '12276.693' │ 123321 │
│ 1 │ 'hono' │ '37.041' │ '31.568' │ '13459.347' │ 135594 │
└─────────┴────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyHono vs hono Speedup: 0.912x |
notaphplover
requested changes
Apr 27, 2025
Member
notaphplover
left a comment
There was a problem hiding this comment.
It looks good. Let's update fastify to allow non Error rejections and we're ready to merge
packages/http/libraries/fastify/src/adapter/InversifyFastifyHttpAdapter.ts
Show resolved
Hide resolved
notaphplover
approved these changes
May 1, 2025
…t/add-global-middleware-guard
Contributor
Benchmarks results:> root@ benchmarks:http:cjs /home/runner/work/monorepo/monorepo
> pnpm run --filter "@inversifyjs/http-benchmarks" benchmarks:run:cjs
> @inversifyjs/http-benchmarks@ benchmarks:run:cjs /home/runner/work/monorepo/monorepo/packages/http/tools/http-benchmarks
> BUILD_TARGET=cjs ./bin/run-cjs.cjs
[CJS] Running benchmarks...
Express Basic Get Request
┌─────────┬───────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼───────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyExpress' │ '107.968' │ '45.017' │ '4140.502' │ 45798 │
│ 1 │ 'express' │ '97.807' │ '42.737' │ '4596.857' │ 50819 │
│ 2 │ 'NestJSExpress' │ '106.671' │ '45.485' │ '4197.882' │ 46376 │
└─────────┴───────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyExpress vs express Speedup: 0.901x
currentInversifyExpress vs NestJSExpress Speedup: 0.986x
Express v4 Basic Get Request
┌─────────┬────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyExpress4' │ '93.954' │ '42.014' │ '4800.714' │ 53052 │
│ 1 │ 'express4' │ '92.860' │ '41.697' │ '4859.402' │ 53696 │
└─────────┴────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyExpress4 vs express4 Speedup: 0.988x
Fastify Basic Get Request
┌─────────┬───────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼───────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyFastify' │ '40.915' │ '33.324' │ '12283.481' │ 124041 │
│ 1 │ 'fastify' │ '31.117' │ '26.140' │ '15868.942' │ 159268 │
│ 2 │ 'NestJSFastify' │ '35.583' │ '30.869' │ '14045.988' │ 141736 │
└─────────┴───────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyFastify vs fastify Speedup: 0.774x
currentInversifyFastify vs NestJSFastify Speedup: 0.875x
Hono Basic Get Request
┌─────────┬────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ms) │ Latency med (ms) │ Throughput avg (req/s) │ Samples │
├─────────┼────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼─────────┤
│ 0 │ 'currentInversifyHono' │ '37.468' │ '30.855' │ '13335.761' │ 134277 │
│ 1 │ 'hono' │ '33.548' │ '28.220' │ '14835.517' │ 149370 │
└─────────┴────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴─────────┘
currentInversifyHono vs hono Speedup: 0.899x |
notaphplover
approved these changes
May 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
Refactored
Motivation
This PR resolves #518 and #519