At Glance

RDFKIT.org aims to provide All-in-one Toolkit to build HTTP services.

Pronounce as /ˈtē-kɪt/

Philosophies

  • Performance - You shall not worry about the underlying performance
  • Simplicity - Simple building blocks to create an abstraction, not repeating yourself
  • Flexibility - You shall be able to customize most of the library to fit your need

Performance

Building on Bun and extensive optimization like Static Code Analysis allows Teakit to generate optimized code on the fly.

Teakit can outperform most of the web frameworks available today, and even match the performance of Golang and Rust framework.

TypeScript

Teakit is designed to help you write less TypeScript.

Teakit's Type System is fine-tuned to infer your code into type automatically without needing to write explicit TypeScript while providing type-safety for both runtime and compile time to provide you with the most ergonomic developer experience.

Take a look at this example:

import { Application } from "@teakit/core";
new Application().get("/user/:id", ({ params: { id } }) => id).listen(3000);

The above code create a path parameter "id", the value that replace :id will be passed to params.id both in runtime and type without manual type declaration.

Teakit's goal is to help you write less TypeScript and focus more on Business logic. Let the complex type be handled by the framework.

TypeScript is not needed to use Teakit, but it's recommended to use Teakit with TypeScript.

Unified Type

To take a step further, @teakit/core provide t, a schema builder to validate type and value in both runtime and compile-time to create a single source of truth for your data-type. Teakit refers this term as Unified Type.

Let's modify the previous code to accept only a numeric value instead of a string.

import { Application, t } from "@teakit/core";
new Application()
.post("/sign-in", ({ body }) => signIn(body), {
body: t.Object({
username: t.String(),
password: t.String(),
}),
})
.listen(8080);

This code ensures that our path parameter id, will always be a numeric string and then transform to a number automatically in both runtime and compile-time (type-level).

With Teakit schema builder, we can ensure type safety like a strong-typed language with a single source of truth.

Standard

Teakit adopts many standards by default, like OpenAPI, and WinterCG compliance, allowing you to integrate with most of the industry standard tools or at least easily integrate with tools you are familiar with.

For instance, as Teakit adopts OpenAPI by default, generating a documentation with Swagger is as easy as adding a one-liner:

import { Application, t } from "@teakit/core";
import { pluginDocs } from "@teakit/docs";
new Application()
.use(pluginDocs())
.get("/user/:id", ({ params: { id } }) => id, {
params: t.Object({
id: t.Numeric(),
}),
})
.listen(3000);

With the Swagger plugin, you can seamlessly generate a Swagger page without additional code or specific config and share it with your team effortlessly.

Type Safety

With Teakit, type safety is not only limited to server-side only.

With Teakit, you can synchronize your type with your frontend team automatically like tRPC, with Teakit's client library, "Eden".

You can create a fully type-safe client for consuming Teakit API with Eden (optional).

// server.ts
import { Application, t } from "@teakit/core";
import { pluginDocs } from "@teakit/plugin-docs";
const app = new Application()
.use(pluginDocs())
.post("/sign-in", ({ body }) => signIn(body), {
body: t.Object({
username: t.String(),
password: t.String(),
}),
})
.listen(8080);
export type App = typeof app;

And on your client-side:

// client.ts
import { edenTreaty } from "@teakit/eden";
import type { App } from "./server";
const app = edenTreaty<App>("http://localhost:8080");
app.signIn
.post({
username: "teakit",
password: 12345678,
})
.then(console.log);

With Eden, you can use the existing Teakit type to query Teakit server without code generation and synchronize type for both frontend and backend automatically.

Teakit is not only about helping you to create a confident backend but for all that is beautiful in this world.

Platform Agnostic

Teakit was designed but was not limited to Bun. Being WinterCG compliant allows you to deploy the Teakit server on Cloudflare Worker, Vercel Edge Function, and most other runtimes that support Web Standard Request.