contract.http.with()
Cover every input boundary
Start with HTTP, then add first-party Browser, GraphQL, and gRPC plugins—every contract stays executable and produces the same structured evidence.
import { contract } from "@glubean/sdk";
import { api } from "./configure.ts";
import {
CreateProject,
Project,
ValidationError,
} from "./schemas.ts";
const projects = contract.http.with("projects", {
client: api,
security: "bearer",
});
// @contract
export const createProject = projects("create-project", {
endpoint: "POST /projects",
description: "Create a project with a required name.",
request: CreateProject,
cases: {
created: {
description: "A valid name creates a project.",
body: { name: "Payments API" },
expect: { status: 201, schema: Project },
},
nameEmpty: {
description: "An empty name is rejected.",
body: { name: "" },
expect: { status: 422, schema: ValidationError },
},
nameTooLong: {
description: "Names over 80 characters are rejected.",
body: { name: "x".repeat(81) },
expect: { status: 422, schema: ValidationError },
},
nameMissing: {
description: "The required name field cannot be omitted.",
body: {},
expect: { status: 422, schema: ValidationError },
},
},
});