Get Started

Installation


Overview

Zeta is available on both JSR and NPM:

bun add @aklinker1/zeta
deno add @aklinker1/zeta

Your First App

Zeta apps require input/output validation and OpenAPI docs. These are two core features required for the app to run:

// main.ts
import { createApp } from "@aklinker1/zeta";
import { zodSchemaAdapter } from "@aklinker1/zeta/adapters/zod-schema-adapter";
import z from "zod";

const app = createApp({
  // 1. Tell Zeta we're using Zod for validation
  schemaAdapter: zodSchemaAdapter,
  // 2. Provide minimal info to build an OpenAPI spec
  openApi: {
    info: {
      title: "Simple Zeta App",
      version: "1.0.0",
    },
  },
}).get(
  "/",
  {
    // 3. Provide docs and schemas
    description: "Example description",
    responses: z.object({
      message: z.string(),
    }),
  },
  () => {
    // 4. Return the response body
    return { message: "Hello World!" };
  },
);

app.listen(3000, () => console.log("Server started @ http://localhost:3000"));

Then run the app:

bun run main.ts
deno run --allow-net index.ts

The app will have three routes:

  • / → Returns "hello world" JSON
  • /openapi.json → Returns OpenAPI JSON spec
  • /scalar → The Scalar API Reference UI

Next Steps