diff --git a/examples/typescript/aws/s3/.gitignore b/examples/aws/s3/.gitignore similarity index 100% rename from examples/typescript/aws/s3/.gitignore rename to examples/aws/s3/.gitignore diff --git a/examples/typescript/aws/s3/README.md b/examples/aws/s3/README.md similarity index 100% rename from examples/typescript/aws/s3/README.md rename to examples/aws/s3/README.md diff --git a/examples/typescript/aws/s3/knitwit.json b/examples/aws/s3/knitwit.json similarity index 100% rename from examples/typescript/aws/s3/knitwit.json rename to examples/aws/s3/knitwit.json diff --git a/examples/typescript/aws/s3/package-lock.json b/examples/aws/s3/package-lock.json similarity index 100% rename from examples/typescript/aws/s3/package-lock.json rename to examples/aws/s3/package-lock.json diff --git a/examples/typescript/aws/s3/package.json b/examples/aws/s3/package.json similarity index 100% rename from examples/typescript/aws/s3/package.json rename to examples/aws/s3/package.json diff --git a/examples/typescript/aws/s3/spin.toml b/examples/aws/s3/spin.toml similarity index 100% rename from examples/typescript/aws/s3/spin.toml rename to examples/aws/s3/spin.toml diff --git a/examples/typescript/aws/s3/src/index.ts b/examples/aws/s3/src/index.ts similarity index 100% rename from examples/typescript/aws/s3/src/index.ts rename to examples/aws/s3/src/index.ts diff --git a/examples/typescript/aws/s3/src/spin.ts b/examples/aws/s3/src/spin.ts similarity index 100% rename from examples/typescript/aws/s3/src/spin.ts rename to examples/aws/s3/src/spin.ts diff --git a/examples/typescript/aws/s3/tsconfig.json b/examples/aws/s3/tsconfig.json similarity index 100% rename from examples/typescript/aws/s3/tsconfig.json rename to examples/aws/s3/tsconfig.json diff --git a/examples/typescript/aws/s3/webpack.config.js b/examples/aws/s3/webpack.config.js similarity index 100% rename from examples/typescript/aws/s3/webpack.config.js rename to examples/aws/s3/webpack.config.js diff --git a/examples/typescript/aws/sqs/.gitignore b/examples/aws/sqs/.gitignore similarity index 100% rename from examples/typescript/aws/sqs/.gitignore rename to examples/aws/sqs/.gitignore diff --git a/examples/typescript/aws/sqs/README.md b/examples/aws/sqs/README.md similarity index 100% rename from examples/typescript/aws/sqs/README.md rename to examples/aws/sqs/README.md diff --git a/examples/typescript/aws/sqs/knitwit.json b/examples/aws/sqs/knitwit.json similarity index 100% rename from examples/typescript/aws/sqs/knitwit.json rename to examples/aws/sqs/knitwit.json diff --git a/examples/typescript/aws/sqs/package-lock.json b/examples/aws/sqs/package-lock.json similarity index 100% rename from examples/typescript/aws/sqs/package-lock.json rename to examples/aws/sqs/package-lock.json diff --git a/examples/typescript/aws/sqs/package.json b/examples/aws/sqs/package.json similarity index 100% rename from examples/typescript/aws/sqs/package.json rename to examples/aws/sqs/package.json diff --git a/examples/typescript/aws/sqs/spin.toml b/examples/aws/sqs/spin.toml similarity index 100% rename from examples/typescript/aws/sqs/spin.toml rename to examples/aws/sqs/spin.toml diff --git a/examples/typescript/aws/sqs/src/index.ts b/examples/aws/sqs/src/index.ts similarity index 100% rename from examples/typescript/aws/sqs/src/index.ts rename to examples/aws/sqs/src/index.ts diff --git a/examples/typescript/aws/sqs/src/spin.ts b/examples/aws/sqs/src/spin.ts similarity index 100% rename from examples/typescript/aws/sqs/src/spin.ts rename to examples/aws/sqs/src/spin.ts diff --git a/examples/typescript/aws/sqs/tsconfig.json b/examples/aws/sqs/tsconfig.json similarity index 100% rename from examples/typescript/aws/sqs/tsconfig.json rename to examples/aws/sqs/tsconfig.json diff --git a/examples/typescript/aws/sqs/webpack.config.js b/examples/aws/sqs/webpack.config.js similarity index 100% rename from examples/typescript/aws/sqs/webpack.config.js rename to examples/aws/sqs/webpack.config.js diff --git a/examples/typescript/blob-storage/backblaze/.gitignore b/examples/blob-storage/backblaze/.gitignore similarity index 100% rename from examples/typescript/blob-storage/backblaze/.gitignore rename to examples/blob-storage/backblaze/.gitignore diff --git a/examples/typescript/blob-storage/backblaze/README.md b/examples/blob-storage/backblaze/README.md similarity index 100% rename from examples/typescript/blob-storage/backblaze/README.md rename to examples/blob-storage/backblaze/README.md diff --git a/examples/typescript/blob-storage/backblaze/knitwit.json b/examples/blob-storage/backblaze/knitwit.json similarity index 100% rename from examples/typescript/blob-storage/backblaze/knitwit.json rename to examples/blob-storage/backblaze/knitwit.json diff --git a/examples/typescript/blob-storage/backblaze/package-lock.json b/examples/blob-storage/backblaze/package-lock.json similarity index 100% rename from examples/typescript/blob-storage/backblaze/package-lock.json rename to examples/blob-storage/backblaze/package-lock.json diff --git a/examples/typescript/blob-storage/backblaze/package.json b/examples/blob-storage/backblaze/package.json similarity index 100% rename from examples/typescript/blob-storage/backblaze/package.json rename to examples/blob-storage/backblaze/package.json diff --git a/examples/typescript/blob-storage/backblaze/spin.toml b/examples/blob-storage/backblaze/spin.toml similarity index 100% rename from examples/typescript/blob-storage/backblaze/spin.toml rename to examples/blob-storage/backblaze/spin.toml diff --git a/examples/typescript/blob-storage/backblaze/src/index.ts b/examples/blob-storage/backblaze/src/index.ts similarity index 100% rename from examples/typescript/blob-storage/backblaze/src/index.ts rename to examples/blob-storage/backblaze/src/index.ts diff --git a/examples/typescript/blob-storage/backblaze/src/spin.ts b/examples/blob-storage/backblaze/src/spin.ts similarity index 100% rename from examples/typescript/blob-storage/backblaze/src/spin.ts rename to examples/blob-storage/backblaze/src/spin.ts diff --git a/examples/typescript/blob-storage/backblaze/tsconfig.json b/examples/blob-storage/backblaze/tsconfig.json similarity index 100% rename from examples/typescript/blob-storage/backblaze/tsconfig.json rename to examples/blob-storage/backblaze/tsconfig.json diff --git a/examples/typescript/blob-storage/backblaze/webpack.config.js b/examples/blob-storage/backblaze/webpack.config.js similarity index 100% rename from examples/typescript/blob-storage/backblaze/webpack.config.js rename to examples/blob-storage/backblaze/webpack.config.js diff --git a/examples/typescript/github/octokit-rest/.gitignore b/examples/github/octokit-rest/.gitignore similarity index 100% rename from examples/typescript/github/octokit-rest/.gitignore rename to examples/github/octokit-rest/.gitignore diff --git a/examples/typescript/github/octokit-rest/README.md b/examples/github/octokit-rest/README.md similarity index 100% rename from examples/typescript/github/octokit-rest/README.md rename to examples/github/octokit-rest/README.md diff --git a/examples/typescript/github/octokit-rest/knitwit.json b/examples/github/octokit-rest/knitwit.json similarity index 100% rename from examples/typescript/github/octokit-rest/knitwit.json rename to examples/github/octokit-rest/knitwit.json diff --git a/examples/typescript/github/octokit-rest/package-lock.json b/examples/github/octokit-rest/package-lock.json similarity index 100% rename from examples/typescript/github/octokit-rest/package-lock.json rename to examples/github/octokit-rest/package-lock.json diff --git a/examples/typescript/github/octokit-rest/package.json b/examples/github/octokit-rest/package.json similarity index 100% rename from examples/typescript/github/octokit-rest/package.json rename to examples/github/octokit-rest/package.json diff --git a/examples/typescript/github/octokit-rest/spin.toml b/examples/github/octokit-rest/spin.toml similarity index 100% rename from examples/typescript/github/octokit-rest/spin.toml rename to examples/github/octokit-rest/spin.toml diff --git a/examples/typescript/github/octokit-rest/src/index.ts b/examples/github/octokit-rest/src/index.ts similarity index 100% rename from examples/typescript/github/octokit-rest/src/index.ts rename to examples/github/octokit-rest/src/index.ts diff --git a/examples/typescript/github/octokit-rest/src/spin.ts b/examples/github/octokit-rest/src/spin.ts similarity index 100% rename from examples/typescript/github/octokit-rest/src/spin.ts rename to examples/github/octokit-rest/src/spin.ts diff --git a/examples/typescript/github/octokit-rest/tsconfig.json b/examples/github/octokit-rest/tsconfig.json similarity index 100% rename from examples/typescript/github/octokit-rest/tsconfig.json rename to examples/github/octokit-rest/tsconfig.json diff --git a/examples/typescript/github/octokit-rest/webpack.config.js b/examples/github/octokit-rest/webpack.config.js similarity index 100% rename from examples/typescript/github/octokit-rest/webpack.config.js rename to examples/github/octokit-rest/webpack.config.js diff --git a/examples/typescript/orm/drizzle/.gitignore b/examples/orm/drizzle/.gitignore similarity index 100% rename from examples/typescript/orm/drizzle/.gitignore rename to examples/orm/drizzle/.gitignore diff --git a/examples/typescript/orm/drizzle/README.md b/examples/orm/drizzle/README.md similarity index 100% rename from examples/typescript/orm/drizzle/README.md rename to examples/orm/drizzle/README.md diff --git a/examples/typescript/orm/drizzle/knitwit.json b/examples/orm/drizzle/knitwit.json similarity index 100% rename from examples/typescript/orm/drizzle/knitwit.json rename to examples/orm/drizzle/knitwit.json diff --git a/examples/typescript/orm/drizzle/migrations.sql b/examples/orm/drizzle/migrations.sql similarity index 100% rename from examples/typescript/orm/drizzle/migrations.sql rename to examples/orm/drizzle/migrations.sql diff --git a/examples/typescript/orm/drizzle/package-lock.json b/examples/orm/drizzle/package-lock.json similarity index 100% rename from examples/typescript/orm/drizzle/package-lock.json rename to examples/orm/drizzle/package-lock.json diff --git a/examples/typescript/orm/drizzle/package.json b/examples/orm/drizzle/package.json similarity index 100% rename from examples/typescript/orm/drizzle/package.json rename to examples/orm/drizzle/package.json diff --git a/examples/typescript/orm/drizzle/spin.toml b/examples/orm/drizzle/spin.toml similarity index 100% rename from examples/typescript/orm/drizzle/spin.toml rename to examples/orm/drizzle/spin.toml diff --git a/examples/typescript/orm/drizzle/src/index.ts b/examples/orm/drizzle/src/index.ts similarity index 100% rename from examples/typescript/orm/drizzle/src/index.ts rename to examples/orm/drizzle/src/index.ts diff --git a/examples/typescript/orm/drizzle/src/spin.ts b/examples/orm/drizzle/src/spin.ts similarity index 100% rename from examples/typescript/orm/drizzle/src/spin.ts rename to examples/orm/drizzle/src/spin.ts diff --git a/examples/typescript/orm/drizzle/tsconfig.json b/examples/orm/drizzle/tsconfig.json similarity index 100% rename from examples/typescript/orm/drizzle/tsconfig.json rename to examples/orm/drizzle/tsconfig.json diff --git a/examples/typescript/orm/drizzle/webpack.config.js b/examples/orm/drizzle/webpack.config.js similarity index 100% rename from examples/typescript/orm/drizzle/webpack.config.js rename to examples/orm/drizzle/webpack.config.js diff --git a/examples/typescript/serverless_db/neondb/.gitignore b/examples/serverless_db/neondb/.gitignore similarity index 100% rename from examples/typescript/serverless_db/neondb/.gitignore rename to examples/serverless_db/neondb/.gitignore diff --git a/examples/typescript/serverless_db/neondb/README.md b/examples/serverless_db/neondb/README.md similarity index 100% rename from examples/typescript/serverless_db/neondb/README.md rename to examples/serverless_db/neondb/README.md diff --git a/examples/typescript/serverless_db/neondb/knitwit.json b/examples/serverless_db/neondb/knitwit.json similarity index 100% rename from examples/typescript/serverless_db/neondb/knitwit.json rename to examples/serverless_db/neondb/knitwit.json diff --git a/examples/typescript/serverless_db/neondb/package-lock.json b/examples/serverless_db/neondb/package-lock.json similarity index 100% rename from examples/typescript/serverless_db/neondb/package-lock.json rename to examples/serverless_db/neondb/package-lock.json diff --git a/examples/typescript/serverless_db/neondb/package.json b/examples/serverless_db/neondb/package.json similarity index 100% rename from examples/typescript/serverless_db/neondb/package.json rename to examples/serverless_db/neondb/package.json diff --git a/examples/typescript/serverless_db/neondb/spin.toml b/examples/serverless_db/neondb/spin.toml similarity index 100% rename from examples/typescript/serverless_db/neondb/spin.toml rename to examples/serverless_db/neondb/spin.toml diff --git a/examples/typescript/serverless_db/neondb/src/index.ts b/examples/serverless_db/neondb/src/index.ts similarity index 100% rename from examples/typescript/serverless_db/neondb/src/index.ts rename to examples/serverless_db/neondb/src/index.ts diff --git a/examples/typescript/serverless_db/neondb/src/spin.ts b/examples/serverless_db/neondb/src/spin.ts similarity index 100% rename from examples/typescript/serverless_db/neondb/src/spin.ts rename to examples/serverless_db/neondb/src/spin.ts diff --git a/examples/typescript/serverless_db/neondb/tsconfig.json b/examples/serverless_db/neondb/tsconfig.json similarity index 100% rename from examples/typescript/serverless_db/neondb/tsconfig.json rename to examples/serverless_db/neondb/tsconfig.json diff --git a/examples/typescript/serverless_db/neondb/webpack.config.js b/examples/serverless_db/neondb/webpack.config.js similarity index 100% rename from examples/typescript/serverless_db/neondb/webpack.config.js rename to examples/serverless_db/neondb/webpack.config.js diff --git a/examples/typescript/serverless_db/planetscale/.gitignore b/examples/serverless_db/planetscale/.gitignore similarity index 100% rename from examples/typescript/serverless_db/planetscale/.gitignore rename to examples/serverless_db/planetscale/.gitignore diff --git a/examples/typescript/serverless_db/planetscale/README.md b/examples/serverless_db/planetscale/README.md similarity index 100% rename from examples/typescript/serverless_db/planetscale/README.md rename to examples/serverless_db/planetscale/README.md diff --git a/examples/typescript/serverless_db/planetscale/knitwit.json b/examples/serverless_db/planetscale/knitwit.json similarity index 100% rename from examples/typescript/serverless_db/planetscale/knitwit.json rename to examples/serverless_db/planetscale/knitwit.json diff --git a/examples/typescript/serverless_db/planetscale/package-lock.json b/examples/serverless_db/planetscale/package-lock.json similarity index 100% rename from examples/typescript/serverless_db/planetscale/package-lock.json rename to examples/serverless_db/planetscale/package-lock.json diff --git a/examples/typescript/serverless_db/planetscale/package.json b/examples/serverless_db/planetscale/package.json similarity index 100% rename from examples/typescript/serverless_db/planetscale/package.json rename to examples/serverless_db/planetscale/package.json diff --git a/examples/typescript/serverless_db/planetscale/spin.toml b/examples/serverless_db/planetscale/spin.toml similarity index 100% rename from examples/typescript/serverless_db/planetscale/spin.toml rename to examples/serverless_db/planetscale/spin.toml diff --git a/examples/typescript/serverless_db/planetscale/src/index.ts b/examples/serverless_db/planetscale/src/index.ts similarity index 100% rename from examples/typescript/serverless_db/planetscale/src/index.ts rename to examples/serverless_db/planetscale/src/index.ts diff --git a/examples/typescript/serverless_db/planetscale/src/spin.ts b/examples/serverless_db/planetscale/src/spin.ts similarity index 100% rename from examples/typescript/serverless_db/planetscale/src/spin.ts rename to examples/serverless_db/planetscale/src/spin.ts diff --git a/examples/typescript/serverless_db/planetscale/tsconfig.json b/examples/serverless_db/planetscale/tsconfig.json similarity index 100% rename from examples/typescript/serverless_db/planetscale/tsconfig.json rename to examples/serverless_db/planetscale/tsconfig.json diff --git a/examples/typescript/serverless_db/planetscale/webpack.config.js b/examples/serverless_db/planetscale/webpack.config.js similarity index 100% rename from examples/typescript/serverless_db/planetscale/webpack.config.js rename to examples/serverless_db/planetscale/webpack.config.js diff --git a/examples/typescript/spin-host-apis/spin-kv/README.md b/examples/spin-host-apis/spin-kv/README.md similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/README.md rename to examples/spin-host-apis/spin-kv/README.md diff --git a/examples/typescript/spin-host-apis/spin-kv/knitwit.json b/examples/spin-host-apis/spin-kv/knitwit.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/knitwit.json rename to examples/spin-host-apis/spin-kv/knitwit.json diff --git a/examples/typescript/spin-host-apis/spin-kv/package-lock.json b/examples/spin-host-apis/spin-kv/package-lock.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/package-lock.json rename to examples/spin-host-apis/spin-kv/package-lock.json diff --git a/examples/typescript/spin-host-apis/spin-kv/package.json b/examples/spin-host-apis/spin-kv/package.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/package.json rename to examples/spin-host-apis/spin-kv/package.json diff --git a/examples/typescript/spin-host-apis/spin-kv/spin.toml b/examples/spin-host-apis/spin-kv/spin.toml similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/spin.toml rename to examples/spin-host-apis/spin-kv/spin.toml diff --git a/examples/typescript/spin-host-apis/spin-kv/src/index.ts b/examples/spin-host-apis/spin-kv/src/index.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/src/index.ts rename to examples/spin-host-apis/spin-kv/src/index.ts diff --git a/examples/typescript/spin-host-apis/spin-kv/src/spin.ts b/examples/spin-host-apis/spin-kv/src/spin.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/src/spin.ts rename to examples/spin-host-apis/spin-kv/src/spin.ts diff --git a/examples/typescript/spin-host-apis/spin-kv/tsconfig.json b/examples/spin-host-apis/spin-kv/tsconfig.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/tsconfig.json rename to examples/spin-host-apis/spin-kv/tsconfig.json diff --git a/examples/typescript/spin-host-apis/spin-kv/webpack.config.js b/examples/spin-host-apis/spin-kv/webpack.config.js similarity index 100% rename from examples/typescript/spin-host-apis/spin-kv/webpack.config.js rename to examples/spin-host-apis/spin-kv/webpack.config.js diff --git a/examples/typescript/spin-host-apis/spin-llm/README.md b/examples/spin-host-apis/spin-llm/README.md similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/README.md rename to examples/spin-host-apis/spin-llm/README.md diff --git a/examples/typescript/spin-host-apis/spin-llm/knitwit.json b/examples/spin-host-apis/spin-llm/knitwit.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/knitwit.json rename to examples/spin-host-apis/spin-llm/knitwit.json diff --git a/examples/typescript/spin-host-apis/spin-llm/package-lock.json b/examples/spin-host-apis/spin-llm/package-lock.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/package-lock.json rename to examples/spin-host-apis/spin-llm/package-lock.json diff --git a/examples/typescript/spin-host-apis/spin-llm/package.json b/examples/spin-host-apis/spin-llm/package.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/package.json rename to examples/spin-host-apis/spin-llm/package.json diff --git a/examples/typescript/spin-host-apis/spin-llm/spin.toml b/examples/spin-host-apis/spin-llm/spin.toml similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/spin.toml rename to examples/spin-host-apis/spin-llm/spin.toml diff --git a/examples/typescript/spin-host-apis/spin-llm/src/index.ts b/examples/spin-host-apis/spin-llm/src/index.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/src/index.ts rename to examples/spin-host-apis/spin-llm/src/index.ts diff --git a/examples/typescript/spin-host-apis/spin-llm/src/spin.ts b/examples/spin-host-apis/spin-llm/src/spin.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/src/spin.ts rename to examples/spin-host-apis/spin-llm/src/spin.ts diff --git a/examples/typescript/spin-host-apis/spin-llm/tsconfig.json b/examples/spin-host-apis/spin-llm/tsconfig.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/tsconfig.json rename to examples/spin-host-apis/spin-llm/tsconfig.json diff --git a/examples/typescript/spin-host-apis/spin-llm/webpack.config.js b/examples/spin-host-apis/spin-llm/webpack.config.js similarity index 100% rename from examples/typescript/spin-host-apis/spin-llm/webpack.config.js rename to examples/spin-host-apis/spin-llm/webpack.config.js diff --git a/examples/spin-host-apis/spin-redis/README.md b/examples/spin-host-apis/spin-redis/README.md new file mode 100644 index 00000000..44f6ce1b --- /dev/null +++ b/examples/spin-host-apis/spin-redis/README.md @@ -0,0 +1,23 @@ +# Using Spin Outbound Redis + +This example showcases using outbound Redis using the Spin SDK. + +## Install Dependencies +Install the necessary npm packages: + +```bash +npm install +``` + +## Prerequisites + +- A Redis server is running at `localhost:6379` + +## Building and Running the Example + +```bash +spin build +spin up +``` + +Use e.g. `curl -v http://127.0.0.1:3000/` to test the endpoint. \ No newline at end of file diff --git a/examples/typescript/spin-host-apis/spin-sqlite/knitwit.json b/examples/spin-host-apis/spin-redis/knitwit.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/knitwit.json rename to examples/spin-host-apis/spin-redis/knitwit.json diff --git a/examples/spin-host-apis/spin-redis/package.json b/examples/spin-host-apis/spin-redis/package.json new file mode 100644 index 00000000..b4233a8d --- /dev/null +++ b/examples/spin-host-apis/spin-redis/package.json @@ -0,0 +1,23 @@ +{ + "name": "spin-redis", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -n spin-http -o target/spin-redis.wasm", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "mkdirp": "^3.0.1", + "ts-loader": "^9.4.1", + "typescript": "^4.8.4", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0" + }, + "dependencies": { + "@fermyon/spin-sdk": "^2.0.0-alpha.3" + } +} \ No newline at end of file diff --git a/examples/spin-host-apis/spin-redis/spin.toml b/examples/spin-host-apis/spin-redis/spin.toml new file mode 100644 index 00000000..0255881b --- /dev/null +++ b/examples/spin-host-apis/spin-redis/spin.toml @@ -0,0 +1,19 @@ +spin_manifest_version = 2 + +[application] +authors = ["karthik2804 "] +description = "" +name = "spin-redis" +version = "0.1.0" + +[[trigger.http]] +route = "/..." +component = "spin-redis" + +[component.spin-redis] +source = "target/spin-redis.wasm" +exclude_files = ["**/node_modules"] +allowed_hosts = ["redis://*:*"] +[component.spin-redis.build] +command = "npm run build" +watch = ["src/**/*.ts", "package.json"] diff --git a/examples/spin-host-apis/spin-redis/src/index.ts b/examples/spin-host-apis/spin-redis/src/index.ts new file mode 100644 index 00000000..7f11d5be --- /dev/null +++ b/examples/spin-host-apis/spin-redis/src/index.ts @@ -0,0 +1,24 @@ +import { ResponseBuilder, Redis } from '@fermyon/spin-sdk'; + +const encoder = new TextEncoder(); +const decoder = new TextDecoder(); +const redisAddress = 'redis://localhost:6379/'; + +export async function handler(_req: Request, res: ResponseBuilder) { + try { + let db = Redis.open(redisAddress); + db.set('test', encoder.encode('Hello world')); + let val = db.get('test'); + + if (!val) { + res.status(404); + res.send(); + return; + } + + res.send(val); + } catch (e: any) { + res.status(500); + res.send(`Error: ${JSON.stringify(e.payload)}`); + } +} diff --git a/examples/typescript/spin-host-apis/spin-sqlite/src/spin.ts b/examples/spin-host-apis/spin-redis/src/spin.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/src/spin.ts rename to examples/spin-host-apis/spin-redis/src/spin.ts diff --git a/examples/typescript/spin-host-apis/spin-sqlite/tsconfig.json b/examples/spin-host-apis/spin-redis/tsconfig.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/tsconfig.json rename to examples/spin-host-apis/spin-redis/tsconfig.json diff --git a/examples/typescript/spin-host-apis/spin-sqlite/webpack.config.js b/examples/spin-host-apis/spin-redis/webpack.config.js similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/webpack.config.js rename to examples/spin-host-apis/spin-redis/webpack.config.js diff --git a/examples/typescript/spin-host-apis/spin-sqlite/README.md b/examples/spin-host-apis/spin-sqlite/README.md similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/README.md rename to examples/spin-host-apis/spin-sqlite/README.md diff --git a/examples/typescript/spin-host-apis/spin-variables/knitwit.json b/examples/spin-host-apis/spin-sqlite/knitwit.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/knitwit.json rename to examples/spin-host-apis/spin-sqlite/knitwit.json diff --git a/examples/typescript/spin-host-apis/spin-sqlite/migration.sql b/examples/spin-host-apis/spin-sqlite/migration.sql similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/migration.sql rename to examples/spin-host-apis/spin-sqlite/migration.sql diff --git a/examples/typescript/spin-host-apis/spin-sqlite/package-lock.json b/examples/spin-host-apis/spin-sqlite/package-lock.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/package-lock.json rename to examples/spin-host-apis/spin-sqlite/package-lock.json diff --git a/examples/typescript/spin-host-apis/spin-sqlite/package.json b/examples/spin-host-apis/spin-sqlite/package.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/package.json rename to examples/spin-host-apis/spin-sqlite/package.json diff --git a/examples/typescript/spin-host-apis/spin-sqlite/spin.toml b/examples/spin-host-apis/spin-sqlite/spin.toml similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/spin.toml rename to examples/spin-host-apis/spin-sqlite/spin.toml diff --git a/examples/typescript/spin-host-apis/spin-sqlite/src/index.ts b/examples/spin-host-apis/spin-sqlite/src/index.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-sqlite/src/index.ts rename to examples/spin-host-apis/spin-sqlite/src/index.ts diff --git a/examples/typescript/spin-host-apis/spin-variables/src/spin.ts b/examples/spin-host-apis/spin-sqlite/src/spin.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/src/spin.ts rename to examples/spin-host-apis/spin-sqlite/src/spin.ts diff --git a/examples/typescript/spin-host-apis/spin-variables/tsconfig.json b/examples/spin-host-apis/spin-sqlite/tsconfig.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/tsconfig.json rename to examples/spin-host-apis/spin-sqlite/tsconfig.json diff --git a/examples/typescript/spin-host-apis/spin-variables/webpack.config.js b/examples/spin-host-apis/spin-sqlite/webpack.config.js similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/webpack.config.js rename to examples/spin-host-apis/spin-sqlite/webpack.config.js diff --git a/examples/typescript/spin-host-apis/spin-variables/README.md b/examples/spin-host-apis/spin-variables/README.md similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/README.md rename to examples/spin-host-apis/spin-variables/README.md diff --git a/examples/typescript/upstash/qstash/knitwit.json b/examples/spin-host-apis/spin-variables/knitwit.json similarity index 100% rename from examples/typescript/upstash/qstash/knitwit.json rename to examples/spin-host-apis/spin-variables/knitwit.json diff --git a/examples/typescript/spin-host-apis/spin-variables/package-lock.json b/examples/spin-host-apis/spin-variables/package-lock.json similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/package-lock.json rename to examples/spin-host-apis/spin-variables/package-lock.json diff --git a/examples/typescript/spin-host-apis/spin-variables/package.json b/examples/spin-host-apis/spin-variables/package.json similarity index 88% rename from examples/typescript/spin-host-apis/spin-variables/package.json rename to examples/spin-host-apis/spin-variables/package.json index e8176a14..872ce525 100644 --- a/examples/typescript/spin-host-apis/spin-variables/package.json +++ b/examples/spin-host-apis/spin-variables/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -n spin-http -o target/octokit-rest.wasm", + "build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -n spin-http -o target/spin-variables.wasm", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], diff --git a/examples/typescript/spin-host-apis/spin-variables/spin.toml b/examples/spin-host-apis/spin-variables/spin.toml similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/spin.toml rename to examples/spin-host-apis/spin-variables/spin.toml diff --git a/examples/typescript/spin-host-apis/spin-variables/src/index.ts b/examples/spin-host-apis/spin-variables/src/index.ts similarity index 100% rename from examples/typescript/spin-host-apis/spin-variables/src/index.ts rename to examples/spin-host-apis/spin-variables/src/index.ts diff --git a/examples/typescript/upstash/qstash/src/spin.ts b/examples/spin-host-apis/spin-variables/src/spin.ts similarity index 100% rename from examples/typescript/upstash/qstash/src/spin.ts rename to examples/spin-host-apis/spin-variables/src/spin.ts diff --git a/examples/typescript/upstash/qstash/tsconfig.json b/examples/spin-host-apis/spin-variables/tsconfig.json similarity index 100% rename from examples/typescript/upstash/qstash/tsconfig.json rename to examples/spin-host-apis/spin-variables/tsconfig.json diff --git a/examples/typescript/upstash/qstash/webpack.config.js b/examples/spin-host-apis/spin-variables/webpack.config.js similarity index 100% rename from examples/typescript/upstash/qstash/webpack.config.js rename to examples/spin-host-apis/spin-variables/webpack.config.js diff --git a/examples/typescript/upstash/qstash/.gitignore b/examples/upstash/qstash/.gitignore similarity index 100% rename from examples/typescript/upstash/qstash/.gitignore rename to examples/upstash/qstash/.gitignore diff --git a/examples/typescript/upstash/qstash/README.md b/examples/upstash/qstash/README.md similarity index 100% rename from examples/typescript/upstash/qstash/README.md rename to examples/upstash/qstash/README.md diff --git a/examples/typescript/upstash/vector/knitwit.json b/examples/upstash/qstash/knitwit.json similarity index 100% rename from examples/typescript/upstash/vector/knitwit.json rename to examples/upstash/qstash/knitwit.json diff --git a/examples/typescript/upstash/qstash/package-lock.json b/examples/upstash/qstash/package-lock.json similarity index 100% rename from examples/typescript/upstash/qstash/package-lock.json rename to examples/upstash/qstash/package-lock.json diff --git a/examples/typescript/upstash/qstash/package.json b/examples/upstash/qstash/package.json similarity index 100% rename from examples/typescript/upstash/qstash/package.json rename to examples/upstash/qstash/package.json diff --git a/examples/typescript/upstash/qstash/spin.toml b/examples/upstash/qstash/spin.toml similarity index 100% rename from examples/typescript/upstash/qstash/spin.toml rename to examples/upstash/qstash/spin.toml diff --git a/examples/typescript/upstash/qstash/src/index.ts b/examples/upstash/qstash/src/index.ts similarity index 100% rename from examples/typescript/upstash/qstash/src/index.ts rename to examples/upstash/qstash/src/index.ts diff --git a/examples/typescript/upstash/vector/src/spin.ts b/examples/upstash/qstash/src/spin.ts similarity index 100% rename from examples/typescript/upstash/vector/src/spin.ts rename to examples/upstash/qstash/src/spin.ts diff --git a/examples/typescript/upstash/vector/tsconfig.json b/examples/upstash/qstash/tsconfig.json similarity index 100% rename from examples/typescript/upstash/vector/tsconfig.json rename to examples/upstash/qstash/tsconfig.json diff --git a/examples/typescript/upstash/vector/webpack.config.js b/examples/upstash/qstash/webpack.config.js similarity index 100% rename from examples/typescript/upstash/vector/webpack.config.js rename to examples/upstash/qstash/webpack.config.js diff --git a/examples/typescript/upstash/vector/.gitignore b/examples/upstash/vector/.gitignore similarity index 100% rename from examples/typescript/upstash/vector/.gitignore rename to examples/upstash/vector/.gitignore diff --git a/examples/typescript/upstash/vector/README.md b/examples/upstash/vector/README.md similarity index 100% rename from examples/typescript/upstash/vector/README.md rename to examples/upstash/vector/README.md diff --git a/examples/upstash/vector/knitwit.json b/examples/upstash/vector/knitwit.json new file mode 100644 index 00000000..0d9f4396 --- /dev/null +++ b/examples/upstash/vector/knitwit.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "project": { + "worlds": [ + "spin-http" + ] + }, + "packages": { + "@fermyon/spin-sdk": { + "witPath": "../../bin/wit", + "world": "spin-imports" + } + } +} \ No newline at end of file diff --git a/examples/typescript/upstash/vector/package-lock.json b/examples/upstash/vector/package-lock.json similarity index 100% rename from examples/typescript/upstash/vector/package-lock.json rename to examples/upstash/vector/package-lock.json diff --git a/examples/typescript/upstash/vector/package.json b/examples/upstash/vector/package.json similarity index 100% rename from examples/typescript/upstash/vector/package.json rename to examples/upstash/vector/package.json diff --git a/examples/typescript/upstash/vector/spin.toml b/examples/upstash/vector/spin.toml similarity index 100% rename from examples/typescript/upstash/vector/spin.toml rename to examples/upstash/vector/spin.toml diff --git a/examples/typescript/upstash/vector/src/index.ts b/examples/upstash/vector/src/index.ts similarity index 100% rename from examples/typescript/upstash/vector/src/index.ts rename to examples/upstash/vector/src/index.ts diff --git a/examples/upstash/vector/src/spin.ts b/examples/upstash/vector/src/spin.ts new file mode 100644 index 00000000..9ee47db3 --- /dev/null +++ b/examples/upstash/vector/src/spin.ts @@ -0,0 +1,21 @@ +import { ResponseBuilder } from '@fermyon/spin-sdk'; +import { handler } from '.'; + +//@ts-ignore +addEventListener('fetch', (event: FetchEvent) => { + handleEvent(event); +}); + +async function handleEvent(event: FetchEvent) { + let resolve: any, reject: any; + let responsePromise = new Promise(async (res, rej) => { + resolve = res; + reject = rej; + }); + //@ts-ignore + event.respondWith(responsePromise); + + let res = new ResponseBuilder(resolve); + + await handler(event.request, res); +} diff --git a/examples/upstash/vector/tsconfig.json b/examples/upstash/vector/tsconfig.json new file mode 100644 index 00000000..851fe99f --- /dev/null +++ b/examples/upstash/vector/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "outDir": "./dist/", + "noImplicitAny": true, + "module": "es6", + "target": "es2020", + "jsx": "react", + "skipLibCheck": true, + "lib": [ + "ES2015", + "WebWorker" + ], + "allowJs": true, + "strict": true, + "noImplicitReturns": true, + "moduleResolution": "node" + } +} \ No newline at end of file diff --git a/examples/upstash/vector/webpack.config.js b/examples/upstash/vector/webpack.config.js new file mode 100644 index 00000000..3a767ede --- /dev/null +++ b/examples/upstash/vector/webpack.config.js @@ -0,0 +1,33 @@ +const path = require('path'); +const SpinSdkPlugin = require('@fermyon/spin-sdk/plugins/webpack'); + +module.exports = { + entry: './src/spin.ts', + experiments: { + outputModule: true, + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + ], + }, + resolve: { + extensions: ['.tsx', '.ts', '.js'], + }, + output: { + path: path.resolve(__dirname, './'), + filename: 'dist.js', + module: true, + library: { + type: 'module', + }, + }, + plugins: [new SpinSdkPlugin()], + optimization: { + minimize: false, + }, +};