Skip to content

Commit b644a98

Browse files
authored
Reworded "deafult" link messaging and standardized capitalization of "key value store"
Signed-off-by: MacKenzie Olson <[email protected]>
1 parent a396fd0 commit b644a98

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

content/wasm-functions/using-key-value-store.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ enable_shortcodes = true
1414
- [Deploying to Fermyon Wasm Functions](#deploying-to-fermyon-wasm-functions)
1515
- [Next Steps](#next-steps)
1616

17-
With Spin Key Value Store support in _Fermyon Wasm Functions_, you can persist non-relational data generated by your [Spin](https://spinframework.dev) application across application restarts and updates. _Fermyon Wasm Functions_ will provision and manage the key value store on your behalf, handling the heavy lifting for you. Spin Key Value Stores are isolated to a single application, and components cannot access the store unless explicitly granted permission. This capabilities-based security model ensures that only authorized components can interact with the data. To learn more about the Spin Key Value Store SDK, please visit the [API guide](https://spinframework.dev/v3/kv-store-api-guide).
17+
With Spin key value store support in _Fermyon Wasm Functions_, you can persist non-relational data generated by your [Spin](https://spinframework.dev) application across application restarts and updates. _Fermyon Wasm Functions_ will provision and manage the key value store on your behalf, handling the heavy lifting for you. Spin key value stores are isolated to a single application, and components cannot access the store unless explicitly granted permission. This capabilities-based security model ensures that only authorized components can interact with the data. To learn more about the Spin key value store SDK, please visit the [API guide](https://spinframework.dev/v3/kv-store-api-guide).
1818

19-
As part of this tutorial, we will build a Spin application which leverages the Key Value Store provided by _Fermyon Wasm Functions_ for persistence. Once we have finished implementing the Spin app, we will run it locally using `spin up` for testing purposes, before we deploy it to _Fermyon Wasm Functions_ using the `spin aka deploy` command.
19+
As part of this tutorial, we will build a Spin application which leverages the key value store provided by _Fermyon Wasm Functions_ for persistence. Once we have finished implementing the Spin app, we will run it locally using `spin up` for testing purposes, before we deploy it to _Fermyon Wasm Functions_ using the `spin aka deploy` command.
2020

2121
## About the Fermyon Wasm Functions Key Value Store
2222

@@ -46,7 +46,9 @@ $ npm install
4646

4747
## Grant Key Value Store Permission
4848

49-
To enable a component in Spin to use a Key value Store, you need to [grant it the necessary permissions in the application's manifest](https://spinframework.dev/kv-store-api-guide#granting-key-value-store-permissions-to-components) (`spin.toml`) by adding a label. A label is a developer-defined string that links your component to an external resource. In this case, the resource is a Key Value Store. When deploying to _Fermyon Wasm Functions_, the label must be set to "default" to signal the platform to automatically provision a Key Value Store for your Spin application. While other labels besides "default" can be used for linking to existing resources in a local developer workflow, "default" is required for automatic key value provisioning on _Fermyon Wasm Functions_.
49+
To enable a component in Spin to use a key-value store, you need to [grant it the necessary permissions in the application's manifest](https://spinframework.dev/kv-store-api-guide#granting-key-value-store-permissions-to-components) (`spin.toml`). To do this, add the label of the store to the component's `key_value_stores` in `spin.toml`.
50+
51+
In _Fermyon Wasm Functions_, the only label allowed is `"default"` which signals to the platform to automatically provision a Key Value store for your Spin application.
5052

5153
```toml
5254
[component.hello-key-value-store]
@@ -59,8 +61,8 @@ key_value_stores = [ "default" ]
5961

6062
The `http-js` template generates a simple _Hello World_ example in `src/index.js`. As part of this section, we'll replace the existing code and use the HTTP router, provided by the template, to make our Spin application respond to the following HTTP request patterns:
6163

62-
- `GET /get/:key` for retrieving a value from Key Value Store using the key provided as `:key`
63-
- `POST /set/:key` for storing a value provided as request payload using `:key` in Key Value Store
64+
- `GET /get/:key` for retrieving a value from key value store using the key provided as `:key`
65+
- `POST /set/:key` for storing a value provided as request payload using `:key` in key value store
6466

6567
Let's start by bringing necessary capabilities from the `@fermyon/spin-sdk` package into scope and laying out the routes:
6668

@@ -85,7 +87,7 @@ addEventListener('fetch', async (event) => {
8587
});
8688
```
8789

88-
Incoming `GET` requests at `/get/:key` will be handled by the `handleGetValue` function. As part of the function, we use the Key Value Store APIs provided by the Spin SDK for JavaScript (`import Kv from '@fermyon/spin-sdk'`):
90+
Incoming `GET` requests at `/get/:key` will be handled by the `handleGetValue` function. As part of the function, we use the key value store APIs provided by the Spin SDK for JavaScript (`import Kv from '@fermyon/spin-sdk'`):
8991

9092
```JavaScript
9193
function handleGetValue(key) {
@@ -98,19 +100,19 @@ function handleGetValue(key) {
98100
return new Response(null, { status: 404 });
99101
}
100102

101-
// load JSON data at key from Key Value Store
103+
// load JSON data at key from key value store
102104
let found = store.getJson(key);
103105

104106
// Return an HTTP 200 with corresponding HTTP header and payload
105-
// if something was found at position key in the Key Value Store
107+
// if something was found at position key in the key value store
106108
return new Response(
107109
JSON.stringify(found),
108110
{ status: 200, headers: { "content-type": "application/json" } }
109111
);
110112
}
111113
```
112114

113-
Incoming `POST` requests at `/set/:key` will be handled by the `handleSetValue` function. After the request payload is validated, we use the Key Value Store APIs for persisting the data.
115+
Incoming `POST` requests at `/set/:key` will be handled by the `handleSetValue` function. After the request payload is validated, we use the key value store APIs for persisting the data.
114116

115117
```JavaScript
116118
function handleSetValue(key, requestBody) {
@@ -210,7 +212,7 @@ Move back to the first terminal instance and terminate your Spin application by
210212

211213
## Deploying to Fermyon Wasm Functions
212214

213-
_Fermyon Wasm Functions_ takes care of provisioning a Key Value Store for you. That said, all we have to do is deploying our Spin application using the `spin aka deploy` command:
215+
_Fermyon Wasm Functions_ takes care of provisioning a key value store for you. That said, all we have to do is deploying our Spin application using the `spin aka deploy` command:
214216

215217
<!-- @selectiveCpy -->
216218

0 commit comments

Comments
 (0)