The TypeScript implementation of Connect: Protobuf RPC that works.
APACHE-2.0 License
Bot releases are hidden (Show)
Published by timostamm 30 days ago
This is a beta release for version 2. See here for an introduction.
To give this version a try, run npx @connectrpc/connect-migrate@beta
. Note that connect-query has not been updated yet.
Stream{Request|Response}
types in interceptors for all streaming rpcs by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/1230
createPromiseClient
-> createClient
by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/1236
createPromiseClient
and PromiseClient
by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/1240
Full Changelog: https://github.com/connectrpc/connect-es/compare/v2.0.0-alpha.1...v2.0.0-beta.1
Published by timostamm about 1 month ago
nodeOptions.headers
by @timostamm in https://github.com/connectrpc/connect-es/pull/1219
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.4.0...v1.5.0
To support protobuf editions, @bufbuild/protobuf
had to make breaking changes, more on this here. Upgrading to v2
of @bufbuild/protobuf
will be breaking change for connect users.
The most notable change is that v2 doesn't require a separate plugin anymore! we only need protoc-gen-es
. For most users this will be a simple change of just removing the connect plugin and changing the import path to point to the protobuf generated types:
import { createPromiseClient } from "@connectrpc/connect";
import { createConnectTransport } from "@connectrpc/connect-node";
// Before this was import { ElizaService } from "./gen/eliza_connect.js"
import { ElizaService } from "./gen/eliza_pb.js";
// Alternatively, use createGrpcTransport or createGrpcWebTransport here
// to use one of the other supported protocols.
const transport = createConnectTransport({
httpVersion: "2",
baseUrl: "https://localhost:8443",
nodeOptions: { rejectUnauthorized },
});
const client = createPromiseClient(ElizaService, transport);
const res = await client.say({ sentence });
Please note that this is an alpha release, and APIs might still change. We're also missing documentation yet. But if you want to try it out, we welcome your feedback!
This release is published with the alpha
tag. To install the alpha packages, you can run:
npm install @connectrpc/connect@alpha @bufbuild/protobuf@beta @bufbuild/protoc-gen-es@beta
Published by srikrsna-buf 8 months ago
This release includes support for server-side interceptors! Here's a quick example:
import * as http from "http";
import routes from "./connect";
import { connectNodeAdapter } from "@connectrpc/connect-node";
import type { Interceptor } from "@connectrpc/connect";
const logger: Interceptor = (next) => async (req) => {
console.log(`recevied message on ${req.url}`);
return await next(req);
};
http
.createServer(
connectNodeAdapter({
routes,
interceptors: [logger],
}),
)
.listen(8080);
For more on them please see the docs.
ts_nocheck
plugin option by @timostamm in https://github.com/connectrpc/connect-es/pull/1012
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.3.0...v1.4.0
Published by srikrsna-buf 10 months ago
*TransportOptions
types for connect-node
by @jrschumacher in https://github.com/connectrpc/connect-es/pull/959
instanceof
for ConnectError
by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/974
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.2.1...v1.3.0
Published by timostamm 10 months ago
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.2.0...v1.2.1
Published by smaye81 10 months ago
By default, protoc-gen-connect-es (and all other plugins based on @bufbuild/protoplugin) generate ECMAScript import
and export
statements. For use cases where CommonJS is difficult to avoid, a new plugin option has been added named js_import_style
which can be used to generate CommonJS require()
calls.
Here is an example buf.gen.yaml:
version: v1
plugins:
# You'll need @bufbuild/protoc-gen-es v1.6.0 or later
- plugin: es
out: src/gen
opt: js_import_style=legacy_commonjs
- plugin: connect-es
out: src/gen
opt: js_import_style=legacy_commonjs
To view the full PR, see Support CommonJS in protoc-gen-connect-es
by @timostamm in #956
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.1.4...v1.2.0
Published by smaye81 11 months ago
User-Agent
header in connect-web by @srikrsna-buf in #912.ConnectError
by @srikrsna-buf in #924.ConnectRouter.rpc
overload to not require full ServiceType
by @paul-sachs in #925.Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.1.3...v1.1.4
Published by timostamm 12 months ago
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.1.2...v1.1.3
Published by timostamm about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.1.1...v1.1.2
Published by srikrsna-buf about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.1.0...v1.1.1
Published by srikrsna-buf about 1 year ago
Add support for user provided context values in handlers and clients.
Create a context key with a default value:
export interface User {
id: string;
}
import { createContextKey } from "@connectrpc/connect";
export const kUser = createContextKey<User | undefined>(
undefined // The default value.
);
Use the contextValues
option to provide the context values for each request:
import { fastify } from "fastify";
import routes from "./connect";
import { fastifyConnectPlugin } from "@connectrpc/connect-fastify";
import { authenticate } from "./authenticate.js";
import { kUser } from "./user-ctx.js";
const server = fastify();
await server.register(fastifyConnectPlugin, {
routes,
contextValues: (req) => createContextValues().set(kUser, authenticate(req)),
});
await server.listen({
host: "localhost",
port: 8080,
});
Use the context value in the handler:
import { ConnectRouter } from "@connectrpc/connect";
import { ElizaService } from "./gen/eliza_connect.js";
export default (router: ConnectRouter) => {
// using const say
router.service(ElizaService, {
say: (req, { values }) => {
const currentUser = values.get(kUser);
if (currentUser === undefined) {
throw new ConnectError("Unauthenticated", Code.Unauthenticated);
}
// ...
},
});
};
Can be used in clients too:
import { ElizaService } from "gen/...";
import { createPromiseClient } from "@connectrpc/connect";
import transport from "./transport.js";
import kUser from "user-context.js";
const client = createPromiseClient(ElizeService, trasport);
await client.say({ sentence: "Hi" }, { values: createContextValues().set(kUser, { ... }) });
Which can be accessed in an interceptor:
const tokenInterceptor = (next) => {
return (req) => {
req.header.set("Authorization", `Bearer ${req.values.get(kUser).token}`);
return next(req);
};
};
connect-migrate
by @mkusaka in #837Full Changelog: https://github.com/connectrpc/connect-es/compare/v1.0.0...v1.1.0
This is Connect-ES
's first stable release! It does not contain any user-facing changes.
If you are coming from version 0.13.0 or earlier, run npx @connectrpc/connect-migrate@latest
to update your dependencies. See here for details.
Thanks to all contributors!
Published by srikrsna-buf about 1 year ago
If you are coming from version 0.13.0 or earlier, run
npx @connectrpc/connect-migrate@latest
to update your dependencies. See here for details.
@connectrpc/connect
a peer dependency and pin the version by @srikrsna-buf in #817Full Changelog: https://github.com/connectrpc/connect-es/compare/v0.13.2...v1.0.0-rc1
Published by smaye81 about 1 year ago
If you are coming from version 0.13.0 or earlier, run
npx @connectrpc/connect-migrate@latest
to update your dependencies. See here for details.
throw
and return
on response iterables in the node adaptor by @srikrsna-buf in #775Full Changelog: https://github.com/connectrpc/connect-es/compare/v0.13.1...v0.13.2
Published by timostamm about 1 year ago
To keep Connect well-maintained and responsive to its users' needs over the long term, we're preparing to donate it to a foundation. (More details on that soon!) To cleanly separate Connect from Buf's other code, we're moving development to the connectrpc GitHub organization and to the connectrpc organization on npmjs.com.
This is the first release that publishes packages with the new @connectrpc
scope. To make the switch seamless, we are introducing a small tool that updates all references in your project automatically, @connectrpc/connect-migrate.
The switch is as simple as running a single command:
$ npx @connectrpc/connect-migrate@latest
Scanning... ✓
1 package.json file
1 lock file
5 source files
Updating source files...
src/client.ts ✓
src/server.ts ✓
src/webclient.ts ✓
Updating packages... ✓
package.json ✓
Updating lock file...
package-lock.json ✓
Old package | New package |
---|---|
@bufbuild/connect v0.13.0 | @connectrpc/connect v0.13.1 |
@bufbuild/connect-web v0.13.0 | @connectrpc/connect-web v0.13.1 |
@bufbuild/connect-fastify v0.13.0 | @connectrpc/connect-fastify v0.13.1 |
@bufbuild/connect-node v0.13.0 | @connectrpc/connect-node v0.13.1 |
@bufbuild/connect-next v0.13.0 | @connectrpc/connect-next v0.13.1 |
@bufbuild/connect-express v0.13.0 | @connectrpc/connect-express v0.13.1 |
@bufbuild/protoc-gen-connect-es v0.13.0 | @connectrpc/protoc-gen-connect-es v0.13.1 |
@bufbuild/connect-query v0.4.1 | @connectrpc/connect-query v0.4.2 |
@bufbuild/protoc-gen-connect-query v0.4.1 | @connectrpc/protoc-gen-connect-query v0.4.2 |
@bufbuild/protoc-gen-connect-query-react v0.4.1 | @connectrpc/protoc-gen-connect-query-react v0.4.2 |
Full Changelog: https://github.com/connectrpc/connect-es/compare/v0.13.0...v0.13.1
Published by timostamm about 1 year ago
This release changes the User-Agent used with gRPC and gRPC-web clients. Previously, the User-Agent was @bufbuild/connect-web
, now it is connect-es/0.13.0
. Future releases will bump the version number in the User-Agent string.
AsyncIterable
protocol by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/729
WritableIterable
behavior by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/724
next
to request iterables by @srikrsna-buf in https://github.com/connectrpc/connect-es/pull/743
Full Changelog: https://github.com/connectrpc/connect-es/compare/v0.12.0...v0.13.0
Published by timostamm about 1 year ago
Full Changelog: https://github.com/bufbuild/connect-es/compare/v0.11.0...v0.12.0
Published by smaye81 over 1 year ago
This release makes a change in how response bodies are parsed for Connect unary requests that result in an HTTP error. Previously, all response bodies for unary requests that returned an HTTP error status were parsed with response.json()
. However, this could lead to errors with non-JSON bodies. Now, only responses with a Content-Type
of application/json
will have the body parsed as JSON and added to the resulting Connect error.
For all other errors, the resulting Connect error will show the HTTP status code as the message and the corresponding Connect error code as the code.
To reiterate, this only affects Connect protocol unary requests that end with an HTTP error status code. All other protocols and/or RPC types are unaffected.
Full Changelog: https://github.com/bufbuild/connect-es/compare/v0.10.1...v0.11.0
Published by timostamm over 1 year ago
Full Changelog: https://github.com/bufbuild/connect-es/compare/v0.10.0...v0.10.1