⚔️ Part II — Dia.ts: Forging the New Era

"The clock isn't just ticking. It’s almost out of time."

That’s where we left off. And now, we rebuild.


🧱 The Philosophy: Intent Over Endpoints

Every major backend framework gives you options — too many of them.

REST, RPC, GraphQL, decorators, middlewares, services, DAOs...

Dia.ts rejects all of it.

There is only one way to define an API: As an intent.

export const api = defineAPI({
  input: z.object({ name: z.string() }),
  async handler({ input }) {
    return { message: `hello ${input.name}` }
  }
})

Because freedom without structure becomes chaos.

APIs are not CRUD functions. They are contracts that fulfill intent.

✅ Enforced by design:

  • Type-safe contracts from client to server
  • Pure functional middleware with AbortSignal support
  • Zero dynamic routing — everything precompiled

This isn’t “minimalism.”
This is intentional design — APIs as behavioral declarations.


🧠 Query as Intent

What if instead of asking for data, clients could declare what they want to happen?

"I want to mark this task as done."

Not: "Give me todos where done = false"

Dia.ts supports Intent-based APIs — where the handler isn’t just a fetcher, but a fulfillment engine.

// intent: "mark_done"
export const api = defineAPI({
  input: z.object({ id: z.string() }),
  async handler({ input }) {
    return markTodoDone(input.id)
  }
})

This structure:

  • 🌟 Aligns better with product UX
  • 📚 Logs like event history
  • 🛡 Centralizes auth & validation
  • 🧠 Enables future AI/LLM integrations

APIs stop being endpoints. They become declarative interfaces for action.


⚙️ The Architecture: Composable, Cancelable, Clear

Dia.ts runs 54,000+ RPS — but performance is the result, not the purpose.

Core principles:

  • 🧠 CancelableTask model: every request is interruptible
  • 🔁 Middleware is functional: (ctx, next) => task
  • 📦 Locals are immutable: extend context cleanly
  • 🛑 AbortSignal for timeout-aware computation

This isn’t about middleware stacking — this is about intent pipelines.


🧨 No More Backend Theater

We don’t need another Express clone.
We don’t need dynamic scaffolding that decays over time.

We need a backend that reflects how apps actually evolve:

  • 🌐 Real-time logic from the start
  • 🧩 State = Event history, not mutable props
  • 📖 Logic = Structured intents
  • 🛠 DX = Typed. Pure. Predictable.

Dia.ts is not a toolchain. It’s a philosophy.


📊 Benchmarks Are Proof — Not the Point

Yes, we beat Bun + Elysia.

Yes, we use native Node + no magic.

But that’s not why Dia.ts exists.

We didn’t optimize the old model. We rejected it — and rebuilt something better.

It’s fast because it’s pure.

It’s safe because it’s structured.

It matters because it’s different.


🌱 It’s Early — and That’s the Best Part

Dia.ts is still pre-alpha:

  • CLI needs polish
  • Docs are sparse
  • Surface is evolving

But:

  • ✅ The intent engine works
  • ✅ The cancellation model is solid
  • ✅ The vision is sharp

If you’ve ever thought “Why is backend still like this?” — this is your exit.


🛠 Try It (Experimental)

npm install dia-ts
npm install -g tsx
mkdir -p gen && npx dia-ts init --with client
📄 routes/hello.post.ts
import { z } from "zod"

export const api = defineAPI({
  input: z.object({ name: z.string() }),
  async handler({ input }) {
    return { message: `hello ${input.name}` }
  }
})
npx dia-ts generate-client
  • GitHub
  • npm
  • Status: pre-alpha — but the fire is lit 🔥

🔭 A Glimpse at What’s Next

Dia.ts is just the beginning.
One day, it won’t just be a framework — but a language.
A language built not for “general purpose,”
but for Web backend, and nothing else.

Fully typed. Fully cancelable.
No Node. No legacy. Just intent.


🧨 Why “Web-only” Matters

Web backend isn’t a toy problem.
It’s real-time, stateful, cancelable, multi-tenant, and deeply coupled to product UX.

General-purpose languages like Go or Java weren’t designed for that.
They’re great for infra, not interaction.

The truth is: Web deserves its own language.
One built not for threads or goroutines — but for structured intent, timeout-aware flows, and type-safe UX alignment.

Dia.ts isn’t trying to do everything.
It’s doing the only thing that matters now — Web backend, the right way.

Fast. Safe. Intentful.

Welcome to the Dia.ts era.