diff --git a/test-utils/README.md b/test-utils/README.md new file mode 100644 index 0000000..c453d8b --- /dev/null +++ b/test-utils/README.md @@ -0,0 +1,39 @@ +# test-utils + +Test server for running Tabi apps in tests. + +## Installation + +```typescript +import { TabiTestServer } from "@tabirun/app/test-utils"; +``` + +## Usage + +```typescript +Deno.test("GET /health returns 200", async () => { + const server = new TabiTestServer(); + + server.app.get("/health", (c) => c.json({ status: "ok" })); + server.start(); + + const res = await fetch(server.url("/health")); + assertEquals(res.status, 200); + + await server.stop(); +}); +``` + +## API + +- `new TabiTestServer()` - Create test server instance +- `app` - The underlying `TabiApp` instance +- `start(port?)` - Start server (uses random port if not specified) +- `url(path)` - Get HTTP URL for path +- `wsUrl(path)` - Get WebSocket URL for path +- `stop()` - Gracefully shutdown server + +## Notes + +- Uses port 0 by default to avoid "address in use" errors +- Always call `stop()` after tests to release resources diff --git a/type-utils/README.md b/type-utils/README.md new file mode 100644 index 0000000..9eb0c6e --- /dev/null +++ b/type-utils/README.md @@ -0,0 +1,28 @@ +# type-utils + +Type utilities for internal use. + +## Installation + +```typescript +import { type PublicOf } from "@tabirun/app/type-utils"; +``` + +## Usage + +```typescript +class MyClass { + private _secret = "hidden"; + public name = "visible"; + public greet() { + return "hello"; + } +} + +type MyPublicAPI = PublicOf; +// { name: string; greet: () => string } +``` + +## Types + +- `PublicOf` - Extracts public interface of a class or object