Skip to content

Commit a10859a

Browse files
committed
added variables to planetscale example
Signed-off-by: Vamshi Reddy <vamshiproject02@gmail.com>
1 parent 49a72f7 commit a10859a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

examples/typescript/planetscale/spin.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ authors = ["Fermyon Engineering <engineering@fermyon.com>"]
55
name = "spin-planetscale"
66
version = "1.0.0"
77

8+
[variables]
9+
host = { required = true, secret = true }
10+
username = { required = true, secret = true }
11+
password = { required = true, secret = true }
12+
813
[[trigger.http]]
914
route = "/hello"
1015
component = "planetscale"
1116

17+
[component.planetscale.variables]
18+
host = "{{ host }}"
19+
username = "{{ username }}"
20+
password = "{{ password }}"
21+
22+
1223
[component.planetscale]
1324
source = "target/spin-planetscale.wasm"
1425
allowed_outbound_hosts = ["https://aws.connect.psdb.cloud"]

examples/typescript/planetscale/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {HandleRequest, HttpRequest, HttpResponse} from "@fermyon/spin-sdk"
1+
import {HandleRequest, HttpRequest, HttpResponse, Config} from "@fermyon/spin-sdk"
22

33
import { connect } from '@planetscale/database'
44

55
const config = {
6-
host: '<host>',
7-
username: '<username>',
8-
password: '<password>'
6+
host: Config.get("host"),
7+
username: Config.get("username"),
8+
password: Config.get("password")
99
}
1010

1111
const encoder = new TextEncoder()

0 commit comments

Comments
 (0)