feat(examples): worked example for apis blocks

This commit is contained in:
2026-08-20 08:36:03 +05:30
parent 0ed8351828
commit 63316111cb
2 changed files with 18 additions and 0 deletions
+7
View File
@@ -1084,6 +1084,7 @@
"BackoffStrategy",
"Bucket",
"BudgetViolation",
"BuiltApiRequest",
"Bulkhead",
"BulkheadOptions",
"CSRF_COOKIE",
@@ -1204,6 +1205,7 @@
"UploadScanner",
"assertTenantAccess",
"bridgeRealtime",
"buildApiRequest",
"cacheControl",
"checkPerformanceBudgets",
"collectUploads",
@@ -1229,6 +1231,7 @@
"escapeHtml",
"etag",
"executionContextFromHttp",
"getRequestContext",
"getUser",
"hashPassword",
"isRoomDefinition",
@@ -1260,9 +1263,11 @@
"requestId",
"requestLogger",
"requireAuth",
"requireRequestContext",
"requireTenant",
"resilientCall",
"resolveRequestUrl",
"runWithRequestContext",
"sanitizeFilename",
"saveUpload",
"saveUploadSecure",
@@ -1465,6 +1470,7 @@
"startServer",
"toRequest",
"validateRpcCsrf",
"withServerFnRequestContext",
"writeResponse"
],
"./serve-entry": []
@@ -2782,6 +2788,7 @@
"parseStructuredImports",
"positionAt",
"runtimeTypeOf",
"skipLiteralOrComment",
"sliceSource",
"stripRuntimeFunctionModifiers",
"supportsSyntaxFeature",
@@ -21,6 +21,11 @@ page ApiBlockDemo {
}
}
load server serverSearch {
const users = await api.searchDirectory({ name: "a" })
return { names: users.map((user) => user.name).join(", ") }
}
functions {
client async function search(): Promise<void> {
const users = await api.searchDirectory({ name: nameFilter })
@@ -33,6 +38,12 @@ page ApiBlockDemo {
<button @click="search()">Search</button>
<p class="found" data-text="found">{found}</p>
<p class="failed" data-text="failed">{failed}</p>
<Async source="serverSearch">
<Loading><p class="server-found">Loading…</p></Loading>
<Success data="serverSearch"><p class="server-found">{serverSearch.names}</p></Success>
<Error error="error"><p class="server-found">Failed: {error.message}</p></Error>
</Async>
<p class="bound" api="searchDirectory({ name: 'a' })">loading</p>
</main>
}
}