1.0.0-alpha.15 • Published 4 years ago

@trpcdev/client v1.0.0-alpha.15

Weekly downloads
47
License
MIT
Repository
github
Last release
4 years ago

Motivation

This library is undergoing rapid development and should be considered experimental. 🤙

tRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.

Usage

:construction: Under construction, for now see ./examples

Data transformers

You are able to serialize the output data (in order to be able to transparently use e.g. standard Dates). The transformers need to be added both to the server and the client.

Data transformers currently live on the edges - in client-specific implementation & in the API response adapters. See a reference of how superjson is attached to ..

Internals

HTTP Methods <-> endpoint type mapping

HTTP MethodMappingNotes
GET.queries()Args in query string
POST.mutations()Args in post body
PATCH.subscriptions()Experimental API using long-pulling. Implementation details are likely to change.

Development

yarn install

This will install all dependencies in each project, build them, and symlink them via Lerna

Development workflow

git clone git@github.com:KATT/trpc.git
cd trpc
yarn

In one terminal, run tsdx watch in parallel:

yarn dev

This builds each package to <packages>/<package>/dist and runs the project in watch mode so any edits you save inside <packages>/<package>/src cause a rebuild to <packages>/<package>/dist. The results will stream to to the terminal.

Using the examples/playground

You can play with local examples:

  • yarn playground - runs examples/playground
  • cd examples next-ssg-chat && yarn dev

Running Cypress

(todo)

(In a third terminal) you can run Cypress and it will run your integration tests against the playground/example. If you want to keep integration tests and examples seperate you can copy the example folder to another folder called like app or whatever. Cypress will look for localhost:1234 by default. If you change ports, also make sure to update .github/integration.yaml as well.