Compare commits

..

2 commits

Author SHA1 Message Date
c3e60e3c12
Make the server fetch stuff from federation 2024-10-17 02:42:13 +02:00
f88c63b747
Create the server 2024-10-17 02:40:29 +02:00
5 changed files with 111 additions and 10 deletions

View file

@ -9,7 +9,7 @@
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
<inspection_tool class="UnnecessaryLocalVariableJS" enabled="true" level="WEAK WARNING" enabled_by_default="true" editorAttributes="INFO_ATTRIBUTES">
<inspection_tool class="UnnecessaryLocalVariableJS" enabled="false" level="WEAK WARNING" enabled_by_default="false" editorAttributes="INFO_ATTRIBUTES">
<option name="m_ignoreImmediatelyReturnedVariables" value="false" />
<option name="m_ignoreAnnotatedVariables" value="false" />
</inspection_tool>

View file

@ -0,0 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run main.ts" type="DenoConfigurationType" inputPath="$PROJECT_DIR$/src/main.ts" programParameters="--allow-read --allow-env --allow-net">
<method v="2" />
</configuration>
</component>

View file

@ -4,6 +4,11 @@
},
"imports": {
"@fedify/fedify": "jsr:@fedify/fedify@^1.0.2",
"@std/assert": "jsr:@std/assert@1"
}
"@fedify/redis": "jsr:@fedify/redis@^0.3.0",
"@std/assert": "jsr:@std/assert@1",
"ioredis": "npm:ioredis@^5.4.1"
},
"unstable": [
"temporal"
]
}

View file

@ -3,9 +3,11 @@
"packages": {
"specifiers": {
"jsr:@fedify/fedify@^1.0.2": "jsr:@fedify/fedify@1.0.2",
"jsr:@fedify/redis@^0.3.0": "jsr:@fedify/redis@0.3.0",
"jsr:@hugoalh/http-header-link@^1.0.2": "jsr:@hugoalh/http-header-link@1.0.2",
"jsr:@hugoalh/is-string-singleline@1.0.2": "jsr:@hugoalh/is-string-singleline@1.0.2",
"jsr:@logtape/logtape@^0.6.2": "jsr:@logtape/logtape@0.6.3",
"jsr:@logtape/logtape@^0.6.3": "jsr:@logtape/logtape@0.6.3",
"jsr:@std/assert@1": "jsr:@std/assert@1.0.6",
"jsr:@std/bytes@^1.0.2": "jsr:@std/bytes@1.0.2",
"jsr:@std/encoding@^1.0.5": "jsr:@std/encoding@1.0.5",
@ -14,6 +16,7 @@
"jsr:@std/semver@^1.0.3": "jsr:@std/semver@1.0.3",
"npm:@phensley/language-tag@^1.9.0": "npm:@phensley/language-tag@1.9.0",
"npm:asn1js@^3.0.5": "npm:asn1js@3.0.5",
"npm:ioredis@^5.4.1": "npm:ioredis@5.4.1",
"npm:json-canon@^1.0.1": "npm:json-canon@1.0.1",
"npm:jsonld@^8.3.2": "npm:jsonld@8.3.2",
"npm:multibase@^4.0.6": "npm:multibase@4.0.6",
@ -43,6 +46,12 @@
"npm:url-template@^3.1.1"
]
},
"@fedify/redis@0.3.0": {
"integrity": "48068af7ad24d4f6c6935d6f869659faeb92281a9e796921f9ba7d94e74f8cfc",
"dependencies": [
"jsr:@logtape/logtape@^0.6.3"
]
},
"@hugoalh/http-header-link@1.0.2": {
"integrity": "1f607e34ac0790a0b0759f89ade294ab3a1d211e46a8dea337eaafa26950205f",
"dependencies": [
@ -90,6 +99,10 @@
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"dependencies": {}
},
"@ioredis/commands@1.2.0": {
"integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==",
"dependencies": {}
},
"@multiformats/base-x@4.0.1": {
"integrity": "sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==",
"dependencies": {}
@ -126,10 +139,24 @@
"integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==",
"dependencies": {}
},
"cluster-key-slot@1.1.2": {
"integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==",
"dependencies": {}
},
"data-uri-to-buffer@4.0.1": {
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"dependencies": {}
},
"debug@4.3.7": {
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"dependencies": {
"ms": "ms@2.1.3"
}
},
"denque@2.1.0": {
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
"dependencies": {}
},
"event-target-shim@5.0.1": {
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"dependencies": {}
@ -147,6 +174,20 @@
"fetch-blob": "fetch-blob@3.2.0"
}
},
"ioredis@5.4.1": {
"integrity": "sha512-2YZsvl7jopIa1gaePkeMtd9rAcSjOOjPtpcLlOeusyO+XH2SK5ZcT+UCrElPP+WVIInh2TzeI4XW9ENaSLVVHA==",
"dependencies": {
"@ioredis/commands": "@ioredis/commands@1.2.0",
"cluster-key-slot": "cluster-key-slot@1.1.2",
"debug": "debug@4.3.7",
"denque": "denque@2.1.0",
"lodash.defaults": "lodash.defaults@4.2.0",
"lodash.isarguments": "lodash.isarguments@3.1.0",
"redis-errors": "redis-errors@1.2.0",
"redis-parser": "redis-parser@3.0.0",
"standard-as-callback": "standard-as-callback@2.1.0"
}
},
"json-canon@1.0.1": {
"integrity": "sha512-PQcj4PFOTAQxE8PgoQ4KrM0DcKWZd7S3ELOON8rmysl9I8JuFMgxu1H9v+oZsTPjjkpeS3IHPwLjr7d+gKygnw==",
"dependencies": {}
@ -172,12 +213,24 @@
"integrity": "sha512-CasD9OCEQSFIam2U8efFK81Yeg8vNMTBUqtMOHlrcWQHqUX3HeCl9Dr31u4toV7emlH8Mymk5+9p0lL6mKb/Xw==",
"dependencies": {}
},
"lodash.defaults@4.2.0": {
"integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==",
"dependencies": {}
},
"lodash.isarguments@3.1.0": {
"integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==",
"dependencies": {}
},
"lru-cache@6.0.0": {
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dependencies": {
"yallist": "yallist@4.0.0"
}
},
"ms@2.1.3": {
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"dependencies": {}
},
"multibase@4.0.6": {
"integrity": "sha512-x23pDe5+svdLz/k5JPGCVdfn7Q5mZVMBETiC+ORfO+sor9Sgs0smJzAjfTbM5tckeCqnaUuMYoz+k3RXMmJClQ==",
"dependencies": {
@ -234,10 +287,24 @@
"setimmediate": "setimmediate@1.0.5"
}
},
"redis-errors@1.2.0": {
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
"dependencies": {}
},
"redis-parser@3.0.0": {
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
"dependencies": {
"redis-errors": "redis-errors@1.2.0"
}
},
"setimmediate@1.0.5": {
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
"dependencies": {}
},
"standard-as-callback@2.1.0": {
"integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==",
"dependencies": {}
},
"tslib@2.7.0": {
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
"dependencies": {}
@ -280,7 +347,9 @@
"workspace": {
"dependencies": [
"jsr:@fedify/fedify@^1.0.2",
"jsr:@std/assert@1"
"jsr:@fedify/redis@^0.3.0",
"jsr:@std/assert@1",
"npm:ioredis@^5.4.1"
]
}
}

View file

@ -1,8 +1,30 @@
export function add(a: number, b: number): number {
return a + b;
import {createFederation} from "@fedify/fedify"
import {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts"
import {Redis} from "ioredis";
const federation = createFederation<void>({
kv: new RedisKvStore(
new Redis({}),
{}
),
});
const handler: Deno.ServeHandler = function handler(request) {
const response = federation.fetch(
request,
{
contextData: undefined,
}
)
return response
}
// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts
if (import.meta.main) {
console.log("Add 2 + 3 =", add(2, 3));
}
Deno.serve(
{
port: 8080
},
handler
)