Skip to content

Commit 9bb04e6

Browse files
authored
Merge pull request #9 from fastly/kats/cli-deps
Use @fastly/cli in the starter kit
2 parents 96dbe7e + e52ad26 commit 9bb04e6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

README.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,47 @@ This is the entry point of the application, an event-listener is attached to the
1414

1515
This is where the majority of our application code lives. A single async function is exported named `app`, which is the function that recieves the incoming `FetchEvent` and returns a `Response` instance, which will be sent to the user-agent.
1616

17+
## Running the application
18+
19+
To create an application using this starter kit, create a new directory for your application and switch to it, and then type the following command:
20+
21+
```shell
22+
npm create @fastly/compute@latest -- --language=typescript --starter-kit=kv-store
23+
```
24+
25+
To build and run your new application in the local development environment, type the following command:
26+
27+
```shell
28+
npm run start
29+
```
30+
1731
## Deploying the project to Fastly
1832

1933
Note that Fastly Services have to have unique names within a Fastly Account.
2034

2135
To create and deploy to a new Fastly Service run the command and follow the instructions:
2236

2337
```shell
24-
fastly compute publish
38+
npm run deploy
2539
```
2640

2741
That is it, we now have a Fastly Service, a Fastly KV Store and have them linked together!
2842

2943
You can view real-time logs for the Fastly Service by running:
3044
```shell
31-
fastly log-tail
45+
npx fastly log-tail
3246
```
3347

3448
## Adding entries to the KV Store
3549

3650
It is possible to add key-value pairs to an KV Store using the Fastly CLI like so:
3751
```shell
38-
fastly kv-store-entry create --store-id=$FASTLY_KV_STORE_ID --key-name=$KEY --value=$VALUE
52+
npx fastly kv-store-entry create --store-id=$FASTLY_KV_STORE_ID --key-name=$KEY --value=$VALUE
3953
```
4054

4155
For example, here is how you could add to the KV Store named `my-store` a key named `readme` whose value is the contents of `README.md`:
4256
```shell
43-
fastly kv-store-entry create --store-id="$(fastly kv-store list --json | jq -r '.Data[]|select(.Name=="my-store").ID')" --key-name="readme" --value="$(cat README.md)"
57+
npx fastly kv-store-entry create --store-id="$(npx fastly kv-store list --json | jq -r '.Data[]|select(.Name=="my-store").ID')" --key-name="readme" --value="$(cat README.md)"
4458
```
4559

4660
## Security issues

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"node": "^18.0.0"
88
},
99
"devDependencies": {
10+
"@fastly/cli": "^10.14.0",
1011
"typescript": "^5.0.0"
1112
},
1213
"dependencies": {
@@ -15,6 +16,7 @@
1516
"scripts": {
1617
"prebuild": "tsc",
1718
"build": "js-compute-runtime build/index.js bin/main.wasm",
18-
"deploy": "npm run build && fastly compute deploy"
19+
"start": "fastly compute serve",
20+
"deploy": "fastly compute publish"
1921
}
2022
}

0 commit comments

Comments
 (0)