michaelangeloio / ts-rest

RPC-like client, contract, and server implementation for a pure REST API

Home Page:https://ts-rest.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ts-rest

All Contributors

RPC-like client and server helpers for a magical end to end typed experience

langue typescript npm GitHub GitHub Workflow Status

Introduction

ts-rest provides an RPC-like client side interface over your existing REST APIs, as well as allowing you define a separate contract implementation rather than going for a 'implementation is the contract' approach, which is best suited for smaller or simpler APIs.

If you have non typescript consumers, a public API, or maybe want to add type safety to your existing REST API? ts-rest is what you're looking for!

Features

  • End to end type safety ๐Ÿ›Ÿ
  • Magic RPC-like API ๐Ÿช„
  • Tiny bundle size ๐ŸŒŸ (1kb!)
  • Well-tested and production ready โœ…
  • No Code Generation ๐Ÿƒโ€โ™€๏ธ
  • Zod support for body parsing ๐Ÿ‘ฎโ€โ™€๏ธ
  • Full optional OpenAPI integration ๐Ÿ“

Quickstart

Install the core package

yarn add @ts-rest/core
# Optional react-query integration
yarn add @ts-rest/react-query
# Pick your backend
yarn add @ts-rest/nest @ts-rest/express
# For automatic server OpenAPI gen
yarn add @ts-rest/open-api

Create a contract, implement it on your server then consume it in your client. Incrementally adopt, trial it with your team, then get shipping faster.

๐Ÿ‘‰ Read more on the official Quickstart Guide ๐Ÿ‘ˆ

Stargazers over Time โญ๏ธ

Stargazers over time

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Youssef Gaber
Youssef Gaber

๐Ÿ’ป ๐Ÿค” โš ๏ธ
Per Hermansson
Per Hermansson

๐Ÿ“– ๐Ÿ’ป
Grรฉgory Houllier
Grรฉgory Houllier

๐Ÿ“–
Michael Angelo
Michael Angelo

๐Ÿ“–
Pieter Venter
Pieter Venter

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

About

RPC-like client, contract, and server implementation for a pure REST API

https://ts-rest.com

License:MIT License


Languages

Language:TypeScript 91.4%Language:JavaScript 6.0%Language:CSS 2.1%Language:HTML 0.5%Language:Shell 0.0%