Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/examples_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ jobs:
RESPONSE=$(npm run --silent demo | jq -r '.id')
[[ "$RESPONSE" == '1' ]] && TEST_RESULT=1 || TEST_RESULT=0

# Docs companion for the wasmcloud.com quickstart's "Add persistent
# storage" step. Build-only: skip-wash-dev: true because the
# component imports wasi:keyvalue at runtime and wash dev doesn't
# auto-provision a keyvalue provider in CI. The build pass is what
# catches template/world.wit/jco-std drift, which is the point.
- folder: http-hello-world-hono-persistent-storage
wasm-bin: http_hello_world_hono_persistent_storage.wasm
skip-wash-dev: true
test-command: ''

examples-check:
needs: [components]
if: ${{ always() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
build
generated/**
*.tgz

wit/deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.12.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
new:
command: npm install

build:
command: npm run build
component_path: dist/http_hello_world_hono_persistent_storage.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# `http-hello-world-hono-persistent-storage`

The TypeScript Hono component as it stands at the end of the [wasmcloud.com
quickstart's "Add persistent storage"][quickstart-persistent-storage] step: the
`templates/http-hello-world-hono` starting point plus `wasi:keyvalue` imports in
`wit/world.wit` and the per-name counter in `src/component.ts`.

It exists as a build-tested checkpoint of that quickstart step. If a future
template change drifts from what the docs walk users through, this example's
build (run by the standard examples CI workflow) catches it.

[quickstart-persistent-storage]: https://wasmcloud.com/docs/quickstart/develop-a-webassembly-component#add-persistent-storage

## Run it

```shell
npm install
wash dev
```

```shell
curl 'http://localhost:8000/?name=Bailey'
# Hello x1, Bailey!
curl 'http://localhost:8000/?name=Bailey'
# Hello x2, Bailey!
```

The counter is persisted via `wasi:keyvalue/store` and `wasi:keyvalue/atomics` —
`wash dev` provides an in-memory implementation automatically.

## Build

```shell
npm install && npm run build
```

## WIT

```wit
world typescript-http-hello-world-hono {
import wasi:keyvalue/store@0.2.0-draft;
import wasi:keyvalue/atomics@0.2.0-draft;

export wasi:http/incoming-handler@0.2.6;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts",
"delay": 1000,
"exec": "wash dev"
}
Loading