Skip to content

Commit d9c720a

Browse files
authored
Merge pull request spinframework#200 from ThorstenHans/feature/js-kv-example
Add key-value sample for JavaScript
2 parents a2c9edb + eb49bb2 commit d9c720a

File tree

7 files changed

+1588
-0
lines changed

7 files changed

+1588
-0
lines changed

examples/javascript/kv/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
target
4+
.spin/

examples/javascript/kv/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# `spin-js-sdk` key-value sample
2+
3+
This app demonstrates how to use key-value store APIs with the Spin JavaScript SDK (`spin-js-sdk`).
4+
5+
The app exposes several endpoints using an HTTP trigger:
6+
7+
- `GET /`: Retrieve all keys and values from the store
8+
- `GET /json/:key`: Retrieve a JSON value from the store using its key
9+
- `SET /json/:key`: Stores the entire request payload as JSON for the given key
10+
- `GET /:key`: Retrieve a plain value from the store using its key
11+
- `SET /:key`: Stores the `value` property of the payload as plain text in key-value store
12+
- `DELETE /:key`: Removes a value from the key-value store by its key
13+
14+
The app leverages the `default` key-value store as specified in `spin.toml`.
15+
16+
## Build and run the app locally
17+
18+
To build and run the app locally, you can either use `spin build` and `spin up` or combine both commands and simply run `spin build --up`.

0 commit comments

Comments
 (0)