Skip to content

Commit 340f62d

Browse files
authored
Merge pull request #286 from karthik2804/add_redis_templates
2 parents 4e63a7e + 6915698 commit 340f62d

File tree

21 files changed

+280
-2
lines changed

21 files changed

+280
-2
lines changed

templates/http-js/content/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"@fermyon/knitwit": "https://github.com/fermyon/knitwit"
1919
},
2020
"dependencies": {
21-
"@fermyon/spin-sdk": "^2.0.0"
21+
"@fermyon/spin-sdk": "^2.1.0"
2222
}
2323
}

templates/http-ts/content/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"@fermyon/knitwit": "https://github.com/fermyon/knitwit"
2121
},
2222
"dependencies": {
23-
"@fermyon/spin-sdk": "^2.0.0"
23+
"@fermyon/spin-sdk": "^2.1.0"
2424
}
2525
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
target
4+
.spin/
5+
dist.js
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": 1,
3+
"project": {
4+
"worlds": [
5+
"spin-redis"
6+
]
7+
},
8+
"packages": {}
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "{{project-name | kebab_case}}",
3+
"version": "1.0.0",
4+
"description": "{{project-description}}",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm",
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"postinstall": "knitwit"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "ISC",
14+
"devDependencies": {
15+
"mkdirp": "^3.0.1",
16+
"webpack": "^5.74.0",
17+
"webpack-cli": "^4.10.0",
18+
"@fermyon/knitwit": "https://github.com/fermyon/knitwit"
19+
},
20+
"dependencies": {
21+
"@fermyon/spin-sdk": "^2.1.0"
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
spin_manifest_version = 2
2+
3+
[application]
4+
name = "{{project-name | kebab_case}}"
5+
version = "0.1.0"
6+
authors = ["{{authors}}"]
7+
description = "{{project-description}}"
8+
9+
[application.trigger.redis]
10+
address = "{{redis-address}}"
11+
12+
[[trigger.redis]]
13+
channel = "{{redis-channel}}"
14+
component = "{{project-name | kebab_case}}"
15+
16+
[component.{{project-name | kebab_case}}]
17+
source = "target/{{project-name | kebab_case}}.wasm"
18+
exclude_files = ["**/node_modules"]
19+
[component.{{project-name | kebab_case}}.build]
20+
command = "npm run build"
21+
watch = ["src/**/*.ts", "package.json"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RedisHandler } from "@fermyon/spin-sdk";
2+
3+
const decoder = new TextDecoder();
4+
5+
export class MyRedisHandler extends RedisHandler {
6+
async handleMessage(msg) {
7+
console.log("Received message:", decoder.decode(msg));
8+
}
9+
}
10+
11+
export const inboundRedis = new MyRedisHandler();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const path = require('path');
2+
const SpinSdkPlugin = require("@fermyon/spin-sdk/plugins/webpack")
3+
4+
module.exports = {
5+
entry: './src/index.js',
6+
experiments: {
7+
outputModule: true,
8+
},
9+
output: {
10+
path: path.resolve(__dirname, './'),
11+
filename: 'dist.js',
12+
module: true,
13+
library: {
14+
type: "module",
15+
}
16+
},
17+
plugins: [
18+
new SpinSdkPlugin()
19+
],
20+
optimization: {
21+
minimize: false
22+
},
23+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[application.trigger.redis]
2+
address = "{{redis-address}}"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[trigger.redis]]
2+
channel = "{{redis-channel}}"
3+
component = "{{project-name | kebab_case}}"
4+
5+
[component.{{project-name | kebab_case}}]
6+
source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
7+
allowed_outbound_hosts = []
8+
[component.{{project-name | kebab_case}}.build]
9+
command = "npm run build"
10+
workdir = "{{ output-path }}"

0 commit comments

Comments
 (0)