release: WRNexusJS 0.8.0
Quality / quality (ubuntu-latest) (push) Failing after 21s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-02 23:18:51 +05:30
parent 87507edf59
commit 586a6db8ff
625 changed files with 243608 additions and 11210 deletions
@@ -0,0 +1,31 @@
import { expect, test } from "bun:test";
import { createContext, defineEndpoint } from "../src/index.ts";
import { v } from "@wrnexus/validation";
const user = v.object({ name: v.string().min(2), email: v.string().email() });
const endpoint = defineEndpoint({
input: user,
output: user,
handler(input) {
return input;
},
});
test("typed endpoints unwrap official validation schemas and return bounded validation errors", async () => {
const request = new Request("https://example.test/api/user");
const ctx = createContext(request, new URL(request.url));
const invalid = await endpoint(ctx, { name: "A", email: "bad" });
expect(invalid.status).toBe(400);
expect(await invalid.json()).toEqual({
error: {
code: "VALIDATION_ERROR",
message: "Endpoint validation failed.",
details: {
name: "Must be at least 2 characters",
email: "Must be a valid email",
},
},
});
const valid = await endpoint(ctx, { name: "Ada", email: "ada@example.test" });
expect(await valid.json()).toEqual({ data: { name: "Ada", email: "ada@example.test" } });
});