Skip to content
@weft-sdk

Weft

One interface for every way services talk.
Weft

Weft

One interface for every way services talk.

Write your contracts once. Call weft.http, weft.gql, weft.grpc, weft.kafka, weft.ws and the rest,
in any language. Weft runs the real library underneath: Express, Apollo, KafkaJS, Spring Kafka, FastAPI, franz-go.


npm Go module Conformance Compiler License

Repository  ·  Quick start  ·  Contracts  ·  Docs  ·  Roadmap  ·  Discussions



Why Weft

A modern system talks in many ways at once: REST, GraphQL, gRPC, Kafka, RabbitMQ, WebSockets. Each has its own library, its own types, its own errors, retries and tracing, and the types drift between the service that sends and the one that receives.

Weft is one interface over all of it. You describe what your services say in small, language-neutral contract files. A compiler turns them into typed code for your language. You call weft.*, and the library you already use runs underneath.


Features

One API
Thirteen transports, one way to call them, the same in every language.

Typed end to end
The sender and every receiver share the types generated from the contract.

Your stack stays
Express, KafkaJS, net/http and franz-go run underneath. .raw hands you the original.

Behaviour that matches
Validation, retries, dead letters, deadlines and errors work the same everywhere.

Observable by default
OpenTelemetry traces and metrics on every call, joined across services.

Breaking changes caught
weft check tells you what a change breaks, and the version bump it needs.


How it works

flowchart LR
    A["<b>.weft</b><br>contracts"] --> B["<b>weft</b> compiler<br>Rust"]
    B --> C["checked<br>contracts"]
    C --> D["<b>generated code</b><br>one file per language"]
    D --> E["<b>weft.*</b><br>runtime"]
    E --> F["the real library<br>Express · KafkaJS · net/http · franz-go · …"]
Loading
package orders @version("1.0.0")

type Order { id: uuid  items: OrderItem[]  total: Money }

event order.placed: Order { key: id }

http /v1 {
  POST "/orders"       createOrder(body: CreateOrder) -> Order | OutOfStock
  GET  "/orders/{id}"  getOrder(id: uuid) -> Order?
}
import { weft } from "./weft.gen"

weft.http.post("/orders", ({ body }) => placeOrder(body))      // body is a typed CreateOrder
weft.kafka.on("order.placed", (order) => notifyCustomer(order)) // order is a typed Order
await weft.kafka.publish("order.placed", order)                 // a wrong payload does not compile
await weft.start()

Get started

cargo install --git https://github.com/weft-sdk/weft weft-cli --locked   # the weft CLI
weft init                                                                # in your project

weft init detects TypeScript or Go, asks which transports you use, installs the packages, writes weft.yaml and a first contract, and generates the code.


Transports and languages

Transport TypeScript Go
● weft.http Express net/http
● weft.kafka KafkaJS franz-go
○ weft.gql · weft.grpc · weft.rpc · weft.ws · weft.sse Apollo · grpc-js · tRPC · Socket.io gqlgen · grpc-go
○ weft.mq · weft.nats · weft.redis · weft.cloud · weft.mqtt · weft.pulsar amqplib · nats · ioredis · cloud SDKs amqp091-go · nats.go · go-redis

  ● available now    ○ on the roadmap

The same contracts also target Python, JVM, .NET, Rust, Ruby, PHP, Elixir, Swift and Dart. Each language is a package that passes the same conformance suite, and the full matrix of libraries is in the language docs.


Packages

Where Package
npm @weft-sdk/core · @weft-sdk/http-express · @weft-sdk/kafka-kafkajs
Go go get github.com/weft-sdk/weft/go
CLI cargo install --git https://github.com/weft-sdk/weft weft-cli

Repositories

Repository What is in it
weft The compiler and CLI, the TypeScript and Go packages, the conformance suite, the website and the docs
examples Runnable projects: a TypeScript service and a Go service that share one contract over HTTP and Kafka
action A GitHub Action that catches breaking contract changes, stale generated code and unformatted contracts
vscode-weft VS Code support for .weft files: highlighting, snippets and formatting
tree-sitter-weft A tree-sitter grammar for the contract language, for Neovim, Helix and Zed
homebrew-tap brew install weft-sdk/tap/weft
brand The logo, the colours and the social preview image

Community

Ask a question in Discussions, report a bug in Issues, or read CONTRIBUTING to send a change. Security problems go through private reporting.


Apache-2.0  ·  Contracts in, typed code out.

Popular repositories Loading

  1. .github .github Public

    Organisation profile and default community files for weft-sdk

  2. weft weft Public

    One interface for every way services talk. Write contracts once in .weft files, get typed code for TypeScript and Go, and run on Express, net/http, KafkaJS and franz-go.

    Rust

  3. examples examples Public

    Runnable example projects for Weft: TypeScript and Go services that talk over HTTP and Kafka

    TypeScript

  4. action action Public

    GitHub Action that checks Weft contracts for breaking changes and stale generated code

    TypeScript

  5. vscode-weft vscode-weft Public

    VS Code support for .weft contracts: syntax highlighting, snippets and formatting

    TypeScript

  6. tree-sitter-weft tree-sitter-weft Public

    Tree-sitter grammar for the Weft contract language

    C

Repositories

Showing 8 of 8 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…