-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Express #479
Conversation
if (opts.acceptCompression === undefined) { | ||
opts.acceptCompression = [compressionGzip, compressionBrotli]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults for acceptCompression moved a couple of lines up. Otherwise, createConnectRouter overrides with an empty array as a default, and these defaults never apply.
// we can override all content type parsers (including application/json) in | ||
// this plugin without affecting outer scope | ||
addNoopContentTypeParsers(instance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are adding all known content-types as string and as regex now. From the fastify docs:
Fastify first tries to match a content-type parser with a string value before trying to find a matching RegExp.
if (isUnaryError) { | ||
throw errorFromJsonBytes( | ||
responseBody, | ||
appendHeaders(header, trailer) | ||
appendHeaders(header, trailer), | ||
unaryError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We ran into #469 with fastify, which replies with an application/json content type for a HTTP 404 when application/json was sent.
The logic was changed to raise a ConnectError for the HTTP status code when parsing fails to fix the issue. This change is applied to the transports from @bufbuild/connect-web and @bufbuild/connect-node.
This adds support for the web framework Express, in a similar fashion to Fastify, which was added in #474.
With the help of
ConnectRouter
:... plugging services into an Express server becomes really straight-forward:
Other changes: