Get started

Install from JSR, chain a few routes, export the type, call it with HttpClient.

Install

deno add jsr:@webtools/expressapi

Server

import { HttpServer } from "jsr:@webtools/expressapi";

export const server = new HttpServer()
  .get("/", (_req, res) => res.json({ message: "Hello, World!" }))
  .get("/users/:id", (req, res) => res.json({ id: req.params.id }));

export type AppRouter = typeof server;

server.listen(5050);

Client

From the same repo or another package - import type only. Nothing starts at runtime.

import type { AppRouter } from "./server.ts";
import { HttpClient } from "jsr:@webtools/expressapi";

const client = new HttpClient<AppRouter>({
  baseUrl: "http://localhost:5050",
});

const user = await client.get("/users/:id", { params: { id: "42" } });
//    ^ { id: string }

Next