@aklinker1/zeta 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/zod-schema-adapter.d.mts +17 -0
- package/dist/adapters/zod-schema-adapter.mjs +726 -0
- package/dist/client.d.mts +71 -0
- package/dist/client.mjs +73 -0
- package/dist/index.d.mts +316 -0
- package/dist/index.mjs +1236 -0
- package/dist/schema-IKHh0I39.d.mts +168 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +151 -0
- package/dist/serialization-C8e7ECQ2.mjs +56 -0
- package/dist/testing.d.mts +26 -0
- package/dist/testing.mjs +52 -0
- package/dist/transports/bun-transport.d.mts +7 -0
- package/dist/transports/bun-transport.mjs +14 -0
- package/dist/transports/deno-transport.d.mts +6 -0
- package/dist/transports/deno-transport.mjs +13 -0
- package/dist/types-D9oRVe1E.d.mts +698 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +38 -16
- package/src/adapters/zod-schema-adapter.ts +0 -29
- package/src/app.ts +0 -479
- package/src/client.ts +0 -184
- package/src/errors.ts +0 -529
- package/src/index.ts +0 -5
- package/src/internal/compile-fetch-function.ts +0 -166
- package/src/internal/compile-route-handler.ts +0 -194
- package/src/internal/context.ts +0 -65
- package/src/internal/serialization.ts +0 -91
- package/src/internal/utils.ts +0 -191
- package/src/meta.ts +0 -14
- package/src/open-api.ts +0 -273
- package/src/schema.ts +0 -271
- package/src/status.ts +0 -143
- package/src/testing.ts +0 -62
- package/src/transports/bun-transport.ts +0 -17
- package/src/transports/deno-transport.ts +0 -13
- package/src/types.ts +0 -1102
package/src/testing.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for testing your server-side application.
|
|
3
|
-
*
|
|
4
|
-
* You don't need to use these utils, you can call the app's `fetch` function directly.
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* const app = createApp()
|
|
8
|
-
* .get("/example", () => "Hello, world!")
|
|
9
|
-
* const fetch = app.build();
|
|
10
|
-
*
|
|
11
|
-
* const res = await fetch("http://test/example");
|
|
12
|
-
* expect(res.status).toEqual(200);
|
|
13
|
-
* expect(await res.text()).toEqual("Hello, world!");
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* If you just care about the response body or error thrown, you can use the `createTestAppClient`.
|
|
17
|
-
*
|
|
18
|
-
* @see {@link createTestAppClient}
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
import {
|
|
22
|
-
createAppClient,
|
|
23
|
-
type AppClient,
|
|
24
|
-
type CreateAppClientOptions,
|
|
25
|
-
type GetClientRoutes,
|
|
26
|
-
} from "./client";
|
|
27
|
-
import type { App } from "./types";
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Create a client for testing your server-side application. When `fetch` is
|
|
31
|
-
* called, the app's `fetch` function is called instead of using the global
|
|
32
|
-
* `fetch`.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const app = createApp()
|
|
37
|
-
* .get("/example", () => "Hello, world!")
|
|
38
|
-
*
|
|
39
|
-
* const client = createTestAppClient(app);
|
|
40
|
-
*
|
|
41
|
-
* expect(await client.get("/example")).toEqual("Hello, world!");
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @param app
|
|
45
|
-
* @param options
|
|
46
|
-
* @returns An app client used to test your server-side application.
|
|
47
|
-
*/
|
|
48
|
-
export function createTestAppClient<TApp extends App>(
|
|
49
|
-
app: TApp,
|
|
50
|
-
options?: Omit<CreateAppClientOptions, "fetch">,
|
|
51
|
-
): AppClient<GetClientRoutes<TApp>> {
|
|
52
|
-
const { baseUrl = "http://localhost" } = options ?? {};
|
|
53
|
-
|
|
54
|
-
const fetch = app.build();
|
|
55
|
-
|
|
56
|
-
return createAppClient({
|
|
57
|
-
baseUrl,
|
|
58
|
-
...options,
|
|
59
|
-
// @ts-expect-error: Fetch type varies between environments
|
|
60
|
-
fetch: (...args) => fetch(new Request(...args)),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Transport } from "../types";
|
|
2
|
-
// @ts-ignore: Bun types may not be available
|
|
3
|
-
import type { ServeFunctionOptions } from "@types/bun";
|
|
4
|
-
|
|
5
|
-
export function createBunTransport(
|
|
6
|
-
options: Omit<ServeFunctionOptions<any, any>, "fetch" | "port">,
|
|
7
|
-
): Transport {
|
|
8
|
-
const listen: Transport["listen"] = (port, fetch, cb) => {
|
|
9
|
-
// @ts-ignore: Bun types may not be available
|
|
10
|
-
Bun.serve({ ...options, port, fetch });
|
|
11
|
-
if (cb) setTimeout(cb, 0);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
listen,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Transport } from "../types";
|
|
2
|
-
|
|
3
|
-
export function createDenoTransport(): Transport {
|
|
4
|
-
const listen: Transport["listen"] = (port, fetch, cb) => {
|
|
5
|
-
// @ts-ignore: Deno types may not be available
|
|
6
|
-
Deno.serve({ port, fetch });
|
|
7
|
-
if (cb) setTimeout(cb, 0);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
listen,
|
|
12
|
-
};
|
|
13
|
-
}
|