Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Deno 7 min read How-to mediumAdept

Build a Typesafe API with tRPC and Deno

tRPC lets a Deno server and client share types through an exported router type, with no schema declarations or code generation. The tutorial installs tRPC v11 and Zod from npm, then builds a file-backed dinosaur API with query, mutation and async-iterable streaming procedures, served by tRPC's standalone HTTP adapter. The client uses splitLink with the batch-stream and subscription links and gets compile-time checking from the imported AppRouter type. Passing a number instead of a string shows Zod rejecting the input at runtime with an invalid_type error.

Related posts

  • Build a REST API with Express, TypeScript, and Deno

    Deno mediumAdept

    Deno runs Express with TypeScript without any TypeScript build configuration: Express is imported through an npm: specifier and its types are pulled in with a @deno-types comment. The walkthrough sets up a server that reads its port from the environment and starts it with explicit Deno permissions (--allow-read, --allow-net, --allow-env), which limits what third-party code can access. It also defines dev and start tasks in deno.jsonc, adds a request-logging middleware, and serves mock user data imported as JSON through /users and /users/:id routes, giving a REST API starting point in under 30 lines.

  • Build a dinosaur runner game with Deno, pt. 1

    Deno mediumAdept

    Part one of a series building a browser dinosaur runner game sets up a Deno project that serves static files and deploys it. It covers `deno init`, adding the Oak framework from JSR, defining `dev` and `start` tasks in deno.json with explicit `--allow-net`/`--allow-read`/`--env-file` permissions, and a minimal Oak server that serves `public/` via `context.send`. It also adds an `/api` router with a health check endpoint, then deploys with `deno deploy` using `src/main.ts` as the entry point.

  • Build a SolidJS app with Deno

    Deno mediumAdept

    A dinosaur catalog app built with SolidJS on the frontend and a Hono API on Deno, scaffolded with Vite via `deno init --npm` and dependencies added from JSR and npm with `deno add`. The walkthrough covers `deno.json` tasks (including Deno 2.1's object-form tasks with descriptions and dependencies), JSX compiler options for Solid, a Vite dev proxy to the API, and two routed pages. It highlights how SolidJS differs from React: signals read as function calls, `For` instead of map, `A` links, and `@solidjs/router` for dynamic routes.

  • How to Build a GraphQL Server with Deno

    Deno mediumAdept

    A GraphQL API server can be built in Deno with the std HTTP Server, the gql middleware, graphql_tools' makeExecutableSchema and graphql_tag. The walkthrough starts with a "Hello, World!" query served at /graphql with GraphiQL enabled, then refactors into separate type definition and resolver files. The expanded version adds Postgres-backed queries (allDinosaurs, oneDinosaur) and an addDinosaur mutation using deno-postgres connection pools and tagged-template SQL. It runs with the --allow-net and --allow-env permission flags.

  • Build a REST API with Express, TypeScript, and Deno, pt. 2

    Deno mediumAdept

    An Express REST API running on Deno gets integration tests via Deno.test using fetch against a configurable staging URL, and HTTP latency benchmarks via Deno.bench in a _bench file. The service is then containerized with a Dockerfile that runs deno cache and a deno.jsonc start task, launched with docker compose, and tested and benchmarked against the running container. Commenting out verbose request logging in middleware noticeably improves benchmark results, and deno bench --json can export results for automated tracking.

The quest for software engineering knowledge.

Look:
Layout: