### Install Dependencies and Run Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/contributing.md Installs project dependencies and starts the Spin application locally for testing. ```bash $ npm install $ cd spin-up-hub $ npm install $ cd .. $ spin build $ npm run spin ``` -------------------------------- ### Setup Spin OTel Dashboards Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_otel.md Initializes and sets up the necessary components for the OTel dashboards. This command should be run after installing the plugin. ```sh spin otel setup ``` -------------------------------- ### Install Spin using the installer script Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Download and run the installer script to install Spin along with a starter set of language templates and plugins. This is an alternative to using Homebrew. ```bash $ curl -fsSL https://spinframework.dev/downloads/install.sh | bash ``` -------------------------------- ### Install Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Install starter templates for Rust, Go, Python, JavaScript, and TypeScript using the 'spin templates install' command. ```bash $ spin templates install --git https://github.com/spinframework/spin --upgrade ``` ```bash $ spin templates install --git https://github.com/spinframework/spin-python-sdk --upgrade ``` ```bash $ spin templates install --git https://github.com/spinframework/spin-js-sdk --upgrade ``` ```bash $ spin templates list ``` -------------------------------- ### Install Spin Templates Source: https://context7.com/spinframework/spin-docs/llms.txt Installs language-specific templates for scaffolding new Spin applications. This is a one-time setup per language. ```bash # Install templates first (one-time setup per language) spin templates install --git https://github.com/spinframework/spin --update # Rust / Go spin templates install --git https://github.com/spinframework/spin-js-sdk --update # TypeScript spin templates install --git https://github.com/spinframework/spin-python-sdk --update # Python ``` -------------------------------- ### Full spin.toml Configuration Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/testing-apps.md An example of a complete `spin.toml` file for an application, including application metadata, HTTP triggers, component configuration, and test tool setup. ```toml spin_manifest_version = 2 [application] name = "my-app" version = "0.1.0" authors = ["Fermyon Engineering "] description = "" [[trigger.http]] route = "/..." component = "my-component" [component.my-component] source = "my-component/target/wasm32-wasip1/release/my_component.wasm" allowed_outbound_hosts = [] key_value_stores = ["default"] [component.my-component.build] command = "cargo build --target wasm32-wasip1 --release" workdir = "my-component" watch = ["src/**/*.rs", "Cargo.toml"] [component.my-component.tool.spin-test] source = "tests/target/wasm32-wasip1/release/tests.wasm" build = "cargo component build --release" dir = "tests" ``` -------------------------------- ### Install Spin KV Explorer Template Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/ai-sentiment-analysis-api-tutorial.md Installs a pre-made template for the Spin KV Explorer from its GitHub repository. ```bash $ spin templates install --git https://github.com/spinframework/spin-kv-explorer ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Install the required Spin SDK and componentize-py packages from your requirements.txt file into your activated virtual environment. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Install Spin Cloud GPU Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_cloud_gpu.md Install the spin-cloud-gpu plugin using the Spin CLI. This command fetches the latest release and installs it automatically. ```bash spin plugins install -u https://github.com/fermyon/spin-cloud-gpu/releases/download/canary/cloud-gpu.json -y ``` -------------------------------- ### Install Pluginify Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_pluginify.md Use this command to install the Pluginify plugin globally on your system. ```bash spin plugins install pluginify ``` -------------------------------- ### Install Cloud Plugin for Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/deploying.md Install the `spin cloud` plugin to deploy Spin applications to Fermyon Cloud. ```bash spin plugins install cloud ``` -------------------------------- ### Application Table Example Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/manifest-reference.md Example of the `application` table in the Spin manifest, defining application-global options like name, version, authors, and description. ```toml [application] name = "greetings" version = "1.0.0" ``` -------------------------------- ### Install SQLite Explorer Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/template_sqlite_explorer.md Use this command to install the SQLite explorer template from its GitHub repository. Ensure you have Spin CLI installed and configured. ```bash spin templates install --upgrade --git https://github.com/karthik2804/spin-sqlite-web-cli/ ``` -------------------------------- ### Start Redis and Spin Application Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/go-components.md Commands to start a Redis server and then build and run a Spin application configured with a Redis trigger. ```bash # first, start redis-server on the default port 6379 $ redis-server --port 6379 # then, start the Spin application $ spin build --up INFO spin_redis_engine: Connecting to Redis server at redis://localhost:6379 INFO spin_redis_engine: Subscribed component 0 (echo-message) to channel: messages ``` -------------------------------- ### Install Spin CLI Source: https://context7.com/spinframework/spin-docs/llms.txt Installs the Spin CLI binary using a hosted script. Ensure the binary is moved to a directory in your system's PATH. ```bash # Linux / macOS curl -fsSL https://spinframework.dev/downloads/install.sh | bash sudo mv ./spin /usr/local/bin/spin # Verify installation spin --version ``` -------------------------------- ### Install and Update Spin Plugins Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/observing-apps.md Use these commands to install or update the `otel` plugin for Spin. ```sh spin plugins update spin plugins install otel ``` -------------------------------- ### Install a Well-Known Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-plugins.md Installs a plugin from the curated Spin plugins catalogue by its name. Use the `--yes` flag to skip confirmation prompts. ```bash $ spin plugins install cloud ``` -------------------------------- ### Install Templates from Spin Git Repository Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-templates.md Installs all templates from the Spin Git repository. You can use the full URL or a shorthand repository ID. ```bash $ spin templates install --git https://github.com/spinframework/spin ``` ```bash $ spin templates install --git fermyon/spin ``` -------------------------------- ### Component Configuration Example Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/manifest-reference.md Example of a component configuration in the Spin manifest. It specifies the source of the WebAssembly module and any files it requires. ```toml [component.greeter] source = "greeting_manager.wasm" files = ["confetti.jpg"] ``` -------------------------------- ### Install Python SDK Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/ai-sentiment-analysis-api-tutorial.md Installs the latest Spin Python SDK. Required for building AI applications using Python. ```bash $ spin templates install --git https://github.com/spinframework/spin-python-sdk --upgrade ``` -------------------------------- ### Install TinyGo Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Installs HTTP and Redis message handler templates for TinyGo. This command also installs templates for other languages if they are in the same repository. ```bash $ spin templates install --git https://github.com/spinframework/spin --update Copying remote template source Installing template redis-go... Installing template http-go... +------------------------------------------------------------------------+ | Name Description | +========================================================================+ | ... other templates omitted ... | | http-go HTTP request handler using (Tiny)Go | | redis-go Redis message handler using (Tiny)Go | | ... other templates omitted ... | +------------------------------------------------------------------------+ ``` -------------------------------- ### Install Spin on Linux/macOS Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Download and install the Spin binary using the provided script. Ensure the binary is moved to a directory in your system's PATH. ```bash $ curl -fsSL https://spinframework.dev/downloads/install.sh | bash ``` ```bash $ sudo mv ./spin /usr/local/bin/spin ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/python-components.md Install project dependencies, including spin-sdk and componentize-py, from the requirements.txt file. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Install Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/blog/announcing-spin-3-5.md Installs or upgrades the Spin templates from the official GitHub repository. ```console $ spin templates install --upgrade --git https://github.com/spinframework/spin ``` -------------------------------- ### Start Redis Server and Spin Application Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/rust-components.md Commands to start a local Redis server and then launch a Spin application configured with a Redis trigger. ```bash # first, start redis-server on the default port 6379 $ redis-server --port 6379 # then, start the Spin application $ spin up --file spin.toml ``` -------------------------------- ### Install Spin with Homebrew Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Install the Spin framework using Homebrew after tapping the Fermyon repository. This command is used on Linux and macOS. ```bash $ brew install spinframework/tap/spin ``` -------------------------------- ### Install Plugin from URL Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-plugins.md Installs a plugin directly from its manifest URL. This is useful for plugins not yet in the catalogue. For authenticated URLs, use the `--auth-header-value` flag. ```bash $ spin plugins install --url https://github.com/spinframework/spin-befunge-sdk/releases/download/v1.4.0/befunge2wasm.json ``` ```bash # URL requires bearer authorization $ spin plugins install --auth-header-value "Bearer 12345678" --url https://example.com/tell-no-one.json ``` ```bash # URL requires basic authorization $ spin plugins install --auth-header-value "Basic c2xhdHM6SWwwdjNmIXNo" --url https://example.com/tell-no-one.json ``` -------------------------------- ### Rust SDK Example Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/redis-outbound.md Example usage of the Spin Redis interface in Rust, demonstrating connection and basic operations. ```APIDOC ## Rust SDK ### Connection To access a Redis instance, use the `Connection::open` function. ```rust let connection = spin_sdk::redis::Connection::open(&address)?; ``` ### Operations You can then call functions on the `Connection` to work with the Redis instance: ```rust connection.set("my-key", &"my-value".into()); let data = connection.get("my-key")?; ``` ### Notes * Keys are of type `&str`. * Bytes parameters are of type `&[u8]` and return values are `Vec`. * Numeric return values are of type `i64`. * All functions wrap the return in `anyhow::Result`. ### `get` Operation Specifics * This returns a `Result>>`. If the key is not found, the return value is `Ok(None)`. ### `del` Operation Specifics * The list of keys is passed as `&[String]`. ### Set Operations Specifics * List arguments are passed as `&[String]` and returned as `Vec`. ### `execute` Operation Specifics * The arguments and results are enums, representing integers, binary payloads, and (for results) status and nil values. ``` -------------------------------- ### List Installed Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-templates.md Displays a list of all currently installed Spin templates. Use the --verbose flag for more details. ```bash $ spin templates list ``` -------------------------------- ### Install Check for Update Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_check_for_update.md Install the plugin using the provided URL. This command adds the plugin to your local spin CLI. ```bash spin plugins install --url https://raw.githubusercontent.com/spinframework/spin-plugins/main/manifests/check-for-update/check-for-update.json ``` -------------------------------- ### Install Local Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/plugin-authoring.md Use the `--file` flag to install a local plugin manifest for development. This allows testing the plugin before it's published to the catalogue. ```bash $ spin plugin install --file practice.json $ spin practice ``` -------------------------------- ### Install KV Explorer Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/template_kv_explorer.md Installs the KV explorer template from its Git repository. Use the --upgrade flag to ensure you have the latest version. ```shell spin templates install --upgrade --git https://github.com/fermyon/spin-kv-explorer ``` -------------------------------- ### Install Spin Python HTTP Template Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/python-components.md Install the `http-py` template from the spin-python-sdk repository to create Python-based HTTP request handlers. ```bash $ spin templates install --git https://github.com/spinframework/spin-python-sdk --update ``` -------------------------------- ### Install Templates from a Local Directory Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-templates.md Installs templates from a local directory on your file system. The specified directory must contain a 'templates' subdirectory. ```bash # Expects to find a directory ~/dev/spin-befunge-sdk/templates $ spin templates install --dir ~/dev/spin-befunge-sdk ``` -------------------------------- ### Install a Spin Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Install a specific plugin, such as the Fermyon Cloud plugin, using its name. The --yes flag bypasses confirmation prompts. ```bash $ spin plugins install cloud --yes ``` -------------------------------- ### Set Up Development Environment Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/contributing-spin.md Add a remote for your fork and create a new branch for your work. Build the Spin CLI and verify compilation. ```bash $ git remote add fork https://github.com//spin $ git checkout -b $ cargo build $ ./target/debug/spin --help $ make test ``` -------------------------------- ### Hub Content Markdown File Example Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/contributing.md Example of a Markdown file for Spin Hub content, including frontmatter metadata and body content. ```toml title = "Rust HTTP trigger template" template = "render_hub_content_body" date = "2022-10-15T00:22:56Z" content-type = "text/html" tags = ["rust", "http"] [extra] author = "fermyon" type = "hub_document" category = "Template" language = "Rust" created_at = "2022-10-15T00:22:56Z" last_updated = "2022-10-15T00:22:56Z" spin_version = ">v0.2" summary = "A template to create an HTTP handler in Rust" url = "https://github.com/spinframework/spin/tree/main/templates/http-rust" --- ``` -------------------------------- ### Install Spin Message Trigger Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_message_trigger.md Install the plugin using the Spin CLI. Ensure you are using the correct URL for the desired release. ```bash spin plugin install --url https://github.com/lee-orr/spin-message-trigger/releases/download/canary/trigger-message.json --yes ``` -------------------------------- ### Runtime Variable Provisioning Examples Source: https://context7.com/spinframework/spin-docs/llms.txt Demonstrates how to provide values for Spin application variables at runtime using environment variables, CLI flags, or JSON files. ```bash # Provide values at runtime via environment variables SPIN_VARIABLE_DB_PASSWORD="s3cr3t" SPIN_VARIABLE_API_BASE="https://staging.example.com" spin up # Provide via CLI flag spin up --variable db_password=s3cr3t --variable api_base=https://staging.example.com # Provide from a JSON file spin up --variable @secrets.json # secrets.json: { "db_password": "s3cr3t", "api_base": "https://staging.example.com" } ``` -------------------------------- ### Build and Run Spin Docs Locally Source: https://github.com/spinframework/spin-docs/blob/main/README.md Follow these commands to set up and run the Spin documentation website on your local machine. Ensure you have npm, node, and Spin installed. ```bash cd spin-up-hub npm ci cd ../ npm ci spin build spin watch # Uses spin watch to run the website and reload when content changes. ``` -------------------------------- ### Install Kinesis Trigger Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_kinesis_trigger.md Install the Kinesis trigger template to easily create new Spin applications that use this trigger. The --update flag ensures you get the latest version. ```sh spin templates install --update --git https://github.com/ogghead/spin-trigger-kinesis ``` -------------------------------- ### Install Spin Cron Trigger Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_cron_trigger.md Install the experimental cron trigger plugin for Spin applications using the provided URL. ```bash spin plugins install --url https://github.com/spinframework/spin-trigger-cron/releases/download/canary/trigger-cron.json ``` -------------------------------- ### Install and Build Spinlet Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spinlet.md Clone the Spinlet repository, navigate into the directory, and then use `spin pluginify` to prepare the plugin. Finally, build the plugin with `spin let`. ```bash git clone https://github.com/cardoso/spinlet cd spinlet spin pluginify -i spin let ``` -------------------------------- ### Install Azure Plugin for Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/deploying.md Install the community `spin azure` plugin to streamline deploying SpinKube and Spin applications to an AKS cluster. ```bash spin plugins install azure ``` -------------------------------- ### Selective Copy Code Block Example Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/contributing-docs.md Use the `` annotation for code blocks intended for copy-pasting. This allows readers to copy only lines starting with '$'. ```bash $ echo "hello" hello ``` -------------------------------- ### Build and Run Spin Application (Python) Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/ai-sentiment-analysis-api-tutorial.md Sets up a Python virtual environment, installs dependencies, and then builds and runs the Spin application locally. ```bash python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt spin build --up ``` -------------------------------- ### Search Available Plugins Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-plugins.md Searches the curated catalogue for available plugins and displays their versions and installation status. Annotations indicate compatibility and installation status. ```bash $ spin plugins search befunge2wasm 1.4.0 [incompatible] cloud 0.8.0 [installed] cloud 0.9.0 trigger-sqs 0.1.0 ``` -------------------------------- ### Install Component Dependencies and Build Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/javascript-components.md Installs project dependencies using npm and then builds the Spin component. The build process compiles JavaScript to a Wasm module. ```bash cd hello-world npm install spin build ``` -------------------------------- ### Python Key-Value Store Operations Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/key-value-store-tutorial.md Utilize the Spin SDK for Python to manage key-value store data. This example handles GET, POST, DELETE, and HEAD requests. ```Python from spin_sdk import http, key_value from spin_sdk.http import Request, Response class IncomingHandler(http.IncomingHandler): def handle_request(self, request: Request) -> Response: with key_value.open_default() as store: match request.method: case "GET": value = store.get(request.uri) if value: status = 200 print(f"Found key {request.uri}") else: status = 404 print(f"Key {request.uri} not found") return Response( status, {"content-type": "text/plain"}, value) case "POST": store.set(request.uri, request.body) print(f"Stored key {request.uri}") return Response(200, {"content-type": "text/plain"}) case "DELETE": store.delete(request.uri) print(f"Deleted key {request.uri}") return Response(200, {"content-type": "text/plain"}) case "HEAD": if store.exists(request.uri): print(f"Found key {request.uri}") return Response(200, {"content-type": "text/plain"}) print(f"Key not found {request.uri}") return Response(404, {"content-type": "text/plain"}) case default: return Response(405, {"content-type": "text/plain"}) ``` -------------------------------- ### Python Component with Redis Operations Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/python-components.md Implement a Python HTTP handler that uses the Spin SDK to interact with Redis. This example demonstrates setting, getting, incrementing, and managing sets in Redis. ```python from spin_sdk import http, redis, variables from spin_sdk.http import Request, Response class IncomingHandler(http.IncomingHandler): def handle_request(self, request: Request) -> Response: with redis.open(variables.get("redis_address")) as db: db.set("foo", b"bar") value = db.get("foo") db.incr("testIncr") db.sadd("testSets", ["hello", "world"]) content = db.smembers("testSets") db.srem("testSets", ["hello"]) assert value == b"bar", f"expected \"bar\", got \"{str(value, 'utf-8')}\"" return Response(200, {"content-type": "text/plain"}, bytes(f"Executed outbound Redis commands: {request.uri}", "utf-8")) ``` -------------------------------- ### Install Akamai Plugin for Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/deploying.md Install the `spin aka` plugin to deploy Spin applications to Fermyon Wasm Functions hosted on Akamai Cloud. ```bash spin plugins install aka ``` -------------------------------- ### Create an HTTP Component in TypeScript Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/javascript-components.md Implement an HTTP component by adding a fetch event listener. This example uses itty-router to handle GET requests for the root path and dynamic routes. ```typescript import { AutoRouter } from 'itty-router'; let router = AutoRouter(); router .get("/", () => new Response("hello universe")) .get('/hello/:name', ({ name }) => `Hello, ${name}!`) //@ts-ignore addEventListener('fetch', async (event: FetchEvent) => { event.respondWith(router.fetch(event.request)); }); ``` -------------------------------- ### Preview Documentation Locally Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/contributing-docs.md Commands to set up the local environment and build/run the Spin documentation for previewing changes, using a preview mode. ```bash $ npm ci $ cd spin-up-hub $ npm ci $ cd .. $ spin build $ spin up -e "PREVIEW_MODE=1" ``` -------------------------------- ### TinyGo SDK - Sending HTTP Requests Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/http-outbound.md Illustrates making outbound HTTP requests in TinyGo using the `spin-go-sdk/http` package. It shows examples for `Get`, `Post`, and a general `Send` function that accepts a standard Go `http.Request` object. ```APIDOC ## HTTP Operations in TinyGo ### Description Provides functions for making outbound HTTP requests. Supports `Get`, `Post`, and a general `Send` function. ### Methods - **Get(url string)**: Sends an HTTP GET request. - **Post(url string, contentType string, body io.Reader)**: Sends an HTTP POST request with a specified content type and body. - **Send(req *http.Request)**: Sends a pre-constructed HTTP request. ### Request Examples ```go import ( spinhttp "github.com/spinframework/spin-go-sdk/v2/http" "net/http" "bytes" ) // GET request res1, err1 := spinhttp.Get("https://random-data-api.fermyon.app/animals/json") // POST request json := []byte(`{"key": "value"}`) res2, err2 := spinhttp.Post("https://example.com/users", "application/json", bytes.NewBuffer(json)) // General Send request (e.g., PUT) request, err := http.NewRequest("PUT", "https://example.com/users/1", bytes.NewBufferString("user data")) request.Header.Add("content-type", "application/json") res3, err3 := spinhttp.Send(request) ``` ### Notes - The `Post` function accepts an `io.Reader` for the request body. - `spinhttp.Send` adapts standard Go `http.Request` objects. - Errors are returned via Go's multiple return value mechanism. ``` -------------------------------- ### Install the canary version of Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Install the latest development version (canary) of Spin by passing '-v canary' to the installer script. This installs the latest commit from the main branch. ```bash $ curl -fsSL https://spinframework.dev/downloads/install.sh | bash -s -- -v canary ``` -------------------------------- ### Build and Run Spin Application Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/key-value-store-tutorial.md Build your Spin application and then run it locally. Ensure your spin.toml includes key_value_stores if you encounter access denied errors. ```bash $ spin build $ spin up ``` -------------------------------- ### Add Components and Brokers Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_message_trigger.md Use `spin add` to set up components, brokers, and gateways. Remember to manually add components to the `Cargo.toml` workspace. ```bash spin add ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Install the necessary Python packages for your component using `pip3 install -r requirements.txt`. ```bash $ pip3 install -r requirements.txt ``` -------------------------------- ### Create Redis Client and Get Value (TinyGo) Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/redis-outbound.md Shows how to initialize a Redis client with an address and fetch a value using a key. Errors are handled via multiple return values. ```go import ( "github.com/spinframework/spin-go-sdk/v2/redis" ) rdb := redis.NewClient(addr) payload, err := rdb.Get(key) ``` -------------------------------- ### Install NPM Dependencies for TypeScript Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Before building a TypeScript component, install its NPM dependencies using `npm install`. ```bash $ npm install added 141 packages, and audited 142 packages in 13s 20 packages are looking for funding run `npm fund` for details found 0 vulnerabilities ``` -------------------------------- ### Spin TOML Configuration for Key Value Store Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/key-value-store-tutorial.md This example shows a more complete `spin.toml` file, including the `key_value_stores` configuration for a component. ```toml spin_manifest_version = 2 [application] name = "spin-key-value" version = "0.1.0" authors = ["Your Name "] description = "A simple application that exercises key-value storage." [[trigger.http]] route = "/..." component = "spin-key-value" [component.spin-key-value] ... key_value_stores = ["default"] ... ``` -------------------------------- ### Install JavaScript/TypeScript Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Installs HTTP request handler templates for JavaScript and TypeScript. Ensure you have npm installed. ```bash $ spin templates install --git https://github.com/spinframework/spin-js-sdk --update Copying remote template source Installing template http-js... Installing template http-ts... +------------------------------------------------------------------------+ | Name Description | +========================================================================+ | http-js HTTP request handler using Javascript | | http-ts HTTP request handler using Typescript | +------------------------------------------------------------------------+ ``` -------------------------------- ### Install Kinesis Trigger Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_kinesis_trigger.md Use this command to install the Kinesis trigger plugin for Spin. Ensure you have the Spin CLI installed. ```sh spin plugins install --url https://github.com/ogghead/spin-trigger-kinesis/releases/download/canary/trigger-kinesis.json ``` -------------------------------- ### Install Spin Rust Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/rust-components.md Installs the Spin templates for Rust components, including HTTP and Redis handlers. Ensure you have Spin installed. ```bash $ spin templates install --git https://github.com/spinframework/spin --update ``` -------------------------------- ### Install Zola SSG Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/template_zola_ssg.md Installs the Zola SSG template using the Spin CLI. Ensure Zola is installed separately first. ```bash $ spin templates install --upgrade --git https://github.com/karthik2804/spin-zola ``` -------------------------------- ### Search for Spin Plugins Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md List all available plugins that can be installed. ```bash $ spin plugins search ``` -------------------------------- ### Install Rust Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Installs HTTP and Redis request handler templates for Rust. This command also installs templates for other languages if they are in the same repository. ```bash $ spin templates install --git https://github.com/spinframework/spin --update Copying remote template source Installing template redis-rust... Installing template http-rust... ... other templates omitted ... +------------------------------------------------------------------------+ | Name Description | +========================================================================+ | ... other templates omitted ... | | http-rust HTTP request handler using Rust | | redis-rust Redis message handler using Rust | | ... other templates omitted ... | +------------------------------------------------------------------------+ ``` -------------------------------- ### Complete Spin Application Manifest with Variables Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/variables.md An example of a complete `spin.toml` file demonstrating application variables and their mapping to a component, including HTTP triggers and component configuration. ```toml spin_manifest_version = 2 [application] name = "api-consumer" version = "0.1.0" description = "A Spin app that makes API requests" [variables] api_token = { required = true } api_uri = { default = "http://my-api.com" } [[trigger.http]] route = "/..." component = "api-consumer" [component.api-consumer] source = "app.wasm" [component.api-consumer.variables] token = "{{ api_token }}" api_uri = "{{ api_uri }}" api_version = "v1" ``` -------------------------------- ### Install NuxtJS SSG Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/template_nuxt.md Use this command to install the NuxtJS SSG template from the specified Git repository. Ensure you have Spin CLI installed. ```bash $ spin templates install --upgrade --git https://github.com/VamshiReddy02/spin-nuxt ``` -------------------------------- ### Setup .NET Aspire Observability Stack Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/observing-apps.md Use this command to set up the .NET Aspire Standalone Dashboard observability stack for Spin. ```sh spin otel setup --aspire ``` -------------------------------- ### Install Latest Spin OTel Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_otel.md Installs the latest stable release of the OTel plugin for Spin. Ensure you have the Spin CLI installed and updated. ```sh spin plugins update spin plugin install otel ``` -------------------------------- ### Connect to Redis and Publish Messages from Go Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/go-components.md Demonstrates connecting to a Redis server using environment variables for address and channel, publishing a message, setting a key-value pair, and retrieving the value. Ensure Redis host is allowed in `spin.toml`. ```go package main import ( "net/http" "os" spin_http "github.com/spinframework/spin-go-sdk/v2/http" "github.com/spinframework/spin-go-sdk/v2/redis" ) func init() { // handler for the http trigger spin_http.Handle(func(w http.ResponseWriter, r *http.Request) { // addr is the environment variable set in `spin.toml` that points to the // address of the Redis server. addr := os.Getenv("REDIS_ADDRESS") // channel is the environment variable set in `spin.toml` that specifies // the Redis channel that the component will publish to. channel := os.Getenv("REDIS_CHANNEL") // payload is the data publish to the redis channel. payload := []byte(`Hello redis from tinygo!`) // create a new redis client. rdb := redis.NewClient(addr) if err := rdb.Publish(channel, payload); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } // set redis `mykey` = `myvalue` if err := rdb.Set("mykey", []byte("myvalue")); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } // get redis payload for `mykey` if payload, err := rdb.Get("mykey"); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } else { w.Write([]byte("mykey value was: ")) w.Write(payload) } }) } ``` -------------------------------- ### Install a specific version of Spin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Use the installer script with the '-v' argument to install a specific version of Spin. Replace 'v1.2.3' with the desired version tag. ```bash $ curl -fsSL https://spinframework.dev/downloads/install.sh | bash -s -- -v v1.2.3 ``` -------------------------------- ### Create TinyGo Spin Application Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/key-value-store-tutorial.md Create a new Spin application using the http-go template for key-value store examples. ```bash $ spin new -t http-go spin-key-value ``` -------------------------------- ### Install a Spin Plugin Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/plugin-authoring.md Use this command to install a plugin from the Spin plugin catalogue. Ensure your local catalogue is up-to-date by running `spin plugins update` first. ```bash spin plugins install kube ``` -------------------------------- ### Build Spin from Source Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/install.md Clone the Spin repository and build the binary using Make. Ensure you have the necessary build toolchain (gcc, make, libssl-dev, pkg-config) installed. ```bash $ git clone https://github.com/spinframework/spin $ cd spin && make build $ ./target/release/spin --help ``` ```bash $ sudo apt-get install build-essential libssl-dev pkg-config ``` -------------------------------- ### List Installed Plugins Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/managing-plugins.md Filters the plugin list to show only those that are currently installed and available for use. ```bash $ spin plugins list --installed ``` -------------------------------- ### Install WasmCP via Script Source: https://github.com/spinframework/spin-docs/blob/main/content/blog/mcp-with-wasmcp.md Installs the latest release binary of wasmcp using a shell script. ```shell curl -fsSL https://raw.githubusercontent.com/wasmcp/wasmcp/main/install.sh | bash ``` -------------------------------- ### Create a New Spin Application Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/spin-application-structure.md Use the `spin new` command with a template to initialize a new Spin application. This sets up the basic directory structure and configuration file. ```bash $ spin new -t http-empty Enter a name for your new application: myapp Description: My application ``` -------------------------------- ### Install Spin Cron Trigger Template Source: https://github.com/spinframework/spin-docs/blob/main/content/api/hub/plugin_spin_cron_trigger.md Install the cron trigger template for Spin applications from its Git repository. ```bash spin templates install --git https://github.com/spinframework/spin-trigger-cron ``` -------------------------------- ### TypeScript SDK Example Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/redis-outbound.md Example usage of the Spin Redis interface in TypeScript, showing connection and basic operations. ```APIDOC ## TypeScript SDK ### Connection Redis functions are available on the `Redis` module. The function names match the operations described generally. ```javascript import { open } from "@spinframework/spin-redis" let db = open("redis://localhost:6379") let value = db.get(key); ``` ### Notes * Key parameters are strings. * Bytes parameters and return values are buffers (TypeScript `Uint8Array`). * Lists are passed and returned as arrays. ### `execute` Operation Specifics * The arguments and results can be either numbers or buffers. (In TypeScript they are union types, e.g. `BigInt | Uint8Array`.) ``` -------------------------------- ### Install Python Spin Templates Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Installs the HTTP request handler template for Python. Requires Python 3.10 or later. ```bash $ spin templates install --git https://github.com/spinframework/spin-python-sdk --update Copying remote template source Installing template http-py... +---------------------------------------------+ | Name Description | +=============================================+ | http-py HTTP request handler using Python | +---------------------------------------------+ ``` -------------------------------- ### Spin TOML Configuration Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/python-components.md Example spin.toml file for a hello-world application, defining application metadata and HTTP trigger configuration. ```toml spin_manifest_version = 2 [application] name = "hello-world" version = "0.1.0" authors = ["Your Name "] description = "" [[trigger.http]] route = "/..." component = "hello-world" [component.hello-world] source = "app.wasm" [component.hello-world.build] command = "componentize-py -w spin-http componentize app -o app.wasm" ``` -------------------------------- ### Install Spin on Windows Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/quickstart.md Download the Windows binary release of Spin from GitHub and place the spin.exe in your system path. ```bash Download the Windows binary release of Spin from GitHub. Unzip the binary release and place the `spin.exe` in your system path. ``` -------------------------------- ### Install JavaScript SDK Source: https://github.com/spinframework/spin-docs/blob/main/content/v3/ai-sentiment-analysis-api-tutorial.md Installs the latest Spin JavaScript SDK. Required for building AI applications using TypeScript/JavaScript. ```bash $ spin templates install --git https://github.com/spinframework/spin-js-sdk --upgrade ```