Skip to content

Commit ecce97f

Browse files
committed
docs: fix sample code for type checking compliance
Enable `deno check --doc-only **/*.md` to verify TypeScript code blocks in Markdown documentation. Fix all type errors in sample code: - Add missing imports to code blocks - Add `await` to async client factory functions - Fix HTTP client: use `.data()` instead of `.json()` - Fix SQL client: use `.rows[0]` instead of `.rows.first()` - Fix GraphQL client: use `.mutation()` instead of `.mutate()` - Fix gRPC streaming: invoke generator functions - Fix Redis hset API signature - Fix MongoDB/SQS client config property names - Fix resource registration to use factory functions - Fix step context access pattern (ctx.resources) Update deno.json check task to validate all Markdown files.
1 parent a40db73 commit ecce97f

9 files changed

Lines changed: 2193 additions & 313 deletions

File tree

.claude/content.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ Every concept should have a runnable code example:
8383
import { client, expect, scenario } from "jsr:@probitas/probitas";
8484

8585
export default scenario("Example")
86-
.resource("http", client.http.createHttpClient())
87-
.step("make request", async ({ http }) => {
86+
.resource(
87+
"http",
88+
() => client.http.createHttpClient({ url: "http://localhost:8080" }),
89+
)
90+
.step("make request", async (ctx) => {
91+
const { http } = ctx.resources;
8892
const res = await http.get("/api/users");
8993
expect(res).toBeOk().toHaveStatus(200);
9094
})

data/index/redis_cache.probitas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default scenario("Redis Cache Test", {
77
client.redis.createRedisClient({
88
url: "redis://localhost:6379",
99
}))
10-
.resource("key", () => `cache:${faker.string.uuid()}`)
10+
.resource("key", () => `cache:${faker.random.uuid()}`)
1111
.setup((ctx) => {
1212
const { redis, key } = ctx.resources;
1313
return async () => {
@@ -19,14 +19,14 @@ export default scenario("Redis Cache Test", {
1919
await redis.set(key, "hello world");
2020
const res = await redis.get(key);
2121

22-
expect(res).toBeOk().toHaveValueMatching("hello world");
22+
expect(res).toBeOk().toHaveValue("hello world");
2323
})
2424
.step("INCR counter", async (ctx) => {
2525
const { redis } = ctx.resources;
2626
await redis.set("test:counter", "0");
2727
const res = await redis.incr("test:counter");
2828

29-
expect(res).toBeOk().toHaveValueMatching(1);
29+
expect(res).toBeOk().toHaveValue(1);
3030

3131
// Cleanup
3232
await redis.del("test:counter");

data/index/user_api.probitas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export default scenario("User API Integration Test", {
44
tags: ["integration", "http", "postgres"],
55
})
66
.resource("user", () => ({
7-
id: faker.string.uuid(),
8-
name: faker.person.fullName(),
7+
id: faker.random.uuid(),
8+
name: faker.name.findName(),
99
email: faker.internet.email(),
1010
}))
1111
.resource("db", () =>
@@ -14,7 +14,7 @@ export default scenario("User API Integration Test", {
1414
host: "localhost",
1515
port: 5432,
1616
database: "app",
17-
user: "testuser",
17+
username: "testuser",
1818
password: "testpassword",
1919
},
2020
}))

deno.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"start": "deno run --allow-net --allow-read main.ts",
99
"build": "deno run --allow-net --allow-read --allow-write --allow-env --allow-run scripts/build.ts",
1010
"preview": "deno run --allow-net --allow-read jsr:@std/http/file-server ./dist",
11-
"check": "deno check main.ts templates/**/*.tsx data/*.ts lib/*.ts scripts/*.ts",
11+
"check": "deno check --doc && deno check --doc-only **/*.md",
12+
"test": "deno test -A --shuffle --parallel",
1213
"verify": "deno fmt && deno lint && deno task check && deno task test",
13-
"test": "deno test --allow-net --allow-read --allow-env",
1414
"generate-api": "deno run --allow-run --allow-write --allow-read --allow-net --allow-env scripts/generate-api-docs.ts"
1515
},
1616
"imports": {
@@ -19,7 +19,6 @@
1919
"marked": "npm:marked@^15.0.12"
2020
},
2121
"exclude": [
22-
"data/index/",
2322
"probitas/"
2423
],
2524
"lint": {

0 commit comments

Comments
 (0)