Skip to content

GOAT for Typescript/ECMAScript

License

Notifications You must be signed in to change notification settings

neat-no/goat-es

Repository files navigation

Typescript / ECMAScript support for GOAT

See GOAT for the canonical GOAT repository.

This repo provides a Typescript GOAT implementation.

Using

See the unit tests for examples. In short, GoatTransport implements the Transport interface defined by connect-es. This means the GoatTransport instance can be passed to createPromiseClient() in lieu of e.g. createGrpcWebTransport().

const underlying = {
    read: () => {
        return Promse.reject("TODO: resolve a Rpc here");
    },
    write: (rpc: Rpc) => {
        throw new Error("TODO: write the Rpc here");
    },
};
const transport = new GoatTransport(underlying);
const ts = createPromiseClient(TestService, transport);
await ts.unary(new Msg({ value: i }));

There is a sample underlying implementation of WebSockets in e2e.test.ts.