diff --git a/.gitignore b/.gitignore index ceaea36..44d3e87 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ dist .yarn/install-state.gz .pnp.* +*~ \ No newline at end of file diff --git a/README.md b/README.md index 35d5324..2234590 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # FediShoop -Federated Shop \ No newline at end of file +Federated Shop + +## Development Setup +Have docker and docker-compose installed and then run in the project root: + +``` +$ docker compose up -d +``` + +The current state of the website will run on [`http://localhost:8000`](http://localhost:8000) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..af0774e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + redis: + image: redis:7-alpine + + app: + image: denoland/deno:alpine + volumes: + - ./fedishoop:/app + ports: + - 8000:8000 + working_dir: /app + command: deno task dev \ No newline at end of file diff --git a/fedishoop/.vscode/extensions.json b/fedishoop/.vscode/extensions.json new file mode 100644 index 0000000..09cf720 --- /dev/null +++ b/fedishoop/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "denoland.vscode-deno" + ] +} diff --git a/fedishoop/.vscode/settings.json b/fedishoop/.vscode/settings.json new file mode 100644 index 0000000..c9a95c0 --- /dev/null +++ b/fedishoop/.vscode/settings.json @@ -0,0 +1,43 @@ +{ + "deno.enable": true, + "deno.unstable": true, + "editor.detectIndentation": false, + "editor.indentSize": 2, + "editor.insertSpaces": true, + "[javascript]": { + "editor.defaultFormatter": "denoland.vscode-deno", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.sortImports": "always" + } + }, + "[javascriptreact]": { + "editor.defaultFormatter": "denoland.vscode-deno", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.sortImports": "always" + } + }, + "[json]": { + "editor.defaultFormatter": "vscode.json-language-features", + "editor.formatOnSave": true + }, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features", + "editor.formatOnSave": true + }, + "[typescript]": { + "editor.defaultFormatter": "denoland.vscode-deno", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.sortImports": "always" + } + }, + "[typescriptreact]": { + "editor.defaultFormatter": "denoland.vscode-deno", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.sortImports": "always" + } + } +} diff --git a/fedishoop/deno.json b/fedishoop/deno.json new file mode 100644 index 0000000..de62d53 --- /dev/null +++ b/fedishoop/deno.json @@ -0,0 +1,21 @@ +{ + "imports": { + "@fedify/fedify": "jsr:@fedify/fedify@^1.0.2", + "@fedify/redis": "jsr:@fedify/redis@^0.2.0", + "@hongminhee/x-forwarded-fetch": "jsr:@hongminhee/x-forwarded-fetch@^0.2.0", + "@logtape/logtape": "jsr:@logtape/logtape@^0.4.3", + "@std/dotenv": "jsr:@std/dotenv@^0.225.2", + "ioredis": "npm:ioredis@^5.4.1" + }, + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "hono/jsx" + }, + "unstable": [ + "temporal" + ], + "tasks": { + "dev": "deno run -A --watch ./main.ts", + "prod": "deno run -A ./main.ts" + } +} diff --git a/fedishoop/deno.lock b/fedishoop/deno.lock new file mode 100644 index 0000000..a8d08ec --- /dev/null +++ b/fedishoop/deno.lock @@ -0,0 +1,354 @@ +{ + "version": "3", + "packages": { + "specifiers": { + "jsr:@fedify/fedify@^1.0.2": "jsr:@fedify/fedify@1.0.2", + "jsr:@fedify/redis@^0.2.0": "jsr:@fedify/redis@0.2.0", + "jsr:@hongminhee/x-forwarded-fetch@^0.2.0": "jsr:@hongminhee/x-forwarded-fetch@0.2.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.4.3": "jsr:@logtape/logtape@0.4.3", + "jsr:@logtape/logtape@^0.6.2": "jsr:@logtape/logtape@0.6.3", + "jsr:@std/bytes@^1.0.2": "jsr:@std/bytes@1.0.2", + "jsr:@std/dotenv@^0.225.2": "jsr:@std/dotenv@0.225.2", + "jsr:@std/encoding@^1.0.5": "jsr:@std/encoding@1.0.5", + "jsr:@std/http@^1.0.6": "jsr:@std/http@1.0.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", + "npm:multicodec@^3.2.1": "npm:multicodec@3.2.1", + "npm:pkijs@^3.2.4": "npm:pkijs@3.2.4", + "npm:uri-template-router@^0.0.16": "npm:uri-template-router@0.0.16", + "npm:url-template@^3.1.1": "npm:url-template@3.1.1" + }, + "jsr": { + "@fedify/fedify@1.0.2": { + "integrity": "e2ad764a08112776110518504d20f82c28c4e7455439e62c48d093dbd4911510", + "dependencies": [ + "jsr:@hugoalh/http-header-link@^1.0.2", + "jsr:@logtape/logtape@^0.6.2", + "jsr:@std/bytes@^1.0.2", + "jsr:@std/encoding@^1.0.5", + "jsr:@std/http@^1.0.6", + "jsr:@std/semver@^1.0.3", + "npm:@phensley/language-tag@^1.9.0", + "npm:asn1js@^3.0.5", + "npm:json-canon@^1.0.1", + "npm:jsonld@^8.3.2", + "npm:multibase@^4.0.6", + "npm:multicodec@^3.2.1", + "npm:pkijs@^3.2.4", + "npm:uri-template-router@^0.0.16", + "npm:url-template@^3.1.1" + ] + }, + "@fedify/redis@0.2.0": { + "integrity": "1a23f8fb587fdf8ab5b2a8d424adfcbd3cfd2c2446d86b7b8271430286f7d329" + }, + "@hongminhee/x-forwarded-fetch@0.2.0": { + "integrity": "8a347e061974e07b480e9461c7d84047e12e92c462fe7679a6f0f59b5c5f48d5" + }, + "@hugoalh/http-header-link@1.0.2": { + "integrity": "1f607e34ac0790a0b0759f89ade294ab3a1d211e46a8dea337eaafa26950205f", + "dependencies": [ + "jsr:@hugoalh/is-string-singleline@1.0.2" + ] + }, + "@hugoalh/is-string-singleline@1.0.2": { + "integrity": "f79dc9930bd89f3534db2efc93293fde5af81648dacbb87afd921cd6a163c9bd" + }, + "@logtape/logtape@0.4.3": { + "integrity": "eac68335a6ffe28265b16bcbc3aea27e10581c09c0c9f5cb11a3acb5cb170945" + }, + "@logtape/logtape@0.6.3": { + "integrity": "64cac3459fddf0455b85d36c8ca3e21764d6b2965c426fb40a0e4a98be436d2b" + }, + "@std/bytes@1.0.2": { + "integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57" + }, + "@std/dotenv@0.225.2": { + "integrity": "e2025dce4de6c7bca21dece8baddd4262b09d5187217e231b033e088e0c4dd23" + }, + "@std/encoding@1.0.5": { + "integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04" + }, + "@std/http@1.0.7": { + "integrity": "9b904fc256678a5c9759f1a53a24a3fdcc59d83dc62099bb472683b6f819194c" + }, + "@std/semver@1.0.3": { + "integrity": "7c139c6076a080eeaa4252c78b95ca5302818d7eafab0470d34cafd9930c13c8" + } + }, + "npm": { + "@digitalbazaar/http-client@3.4.1_ky@0.33.3": { + "integrity": "sha512-Ahk1N+s7urkgj7WvvUND5f8GiWEPfUw0D41hdElaqLgu8wZScI8gdI0q+qWw5N1d35x7GCRH2uk9mi+Uzo9M3g==", + "dependencies": { + "ky": "ky@0.33.3", + "ky-universal": "ky-universal@0.11.0_ky@0.33.3", + "undici": "undici@5.28.4" + } + }, + "@fastify/busboy@2.1.1": { + "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": {} + }, + "@noble/hashes@1.5.0": { + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dependencies": {} + }, + "@phensley/language-tag@1.9.0": { + "integrity": "sha512-nj2uFsnp2SSD/DEGvLqcrpTXerIe9yShGndnwY7p3Z6Ep4m6+GkrgZCNJUc8rKcXWgQmRGC2TUzwG/LlBVtuCA==", + "dependencies": { + "tslib": "tslib@2.7.0" + } + }, + "abort-controller@3.0.0": { + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "event-target-shim@5.0.1" + } + }, + "asn1js@3.0.5": { + "integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==", + "dependencies": { + "pvtsutils": "pvtsutils@1.3.5", + "pvutils": "pvutils@1.1.3", + "tslib": "tslib@2.7.0" + } + }, + "bytestreamjs@2.0.1": { + "integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==", + "dependencies": {} + }, + "canonicalize@1.0.8": { + "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": {} + }, + "fetch-blob@3.2.0": { + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dependencies": { + "node-domexception": "node-domexception@1.0.0", + "web-streams-polyfill": "web-streams-polyfill@3.3.3" + } + }, + "formdata-polyfill@4.0.10": { + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "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": {} + }, + "jsonld@8.3.2": { + "integrity": "sha512-MwBbq95szLwt8eVQ1Bcfwmgju/Y5P2GdtlHE2ncyfuYjIdEhluUVyj1eudacf1mOkWIoS9GpDBTECqhmq7EOaA==", + "dependencies": { + "@digitalbazaar/http-client": "@digitalbazaar/http-client@3.4.1_ky@0.33.3", + "canonicalize": "canonicalize@1.0.8", + "lru-cache": "lru-cache@6.0.0", + "rdf-canonize": "rdf-canonize@3.4.0" + } + }, + "ky-universal@0.11.0_ky@0.33.3": { + "integrity": "sha512-65KyweaWvk+uKKkCrfAf+xqN2/epw1IJDtlyCPxYffFCMR8u1sp2U65NtWpnozYfZxQ6IUzIlvUcw+hQ82U2Xw==", + "dependencies": { + "abort-controller": "abort-controller@3.0.0", + "ky": "ky@0.33.3", + "node-fetch": "node-fetch@3.3.2" + } + }, + "ky@0.33.3": { + "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": { + "@multiformats/base-x": "@multiformats/base-x@4.0.1" + } + }, + "multicodec@3.2.1": { + "integrity": "sha512-+expTPftro8VAW8kfvcuNNNBgb9gPeNYV9dn+z1kJRWF2vih+/S79f2RVeIwmrJBUJ6NT9IUPWnZDQvegEh5pw==", + "dependencies": { + "uint8arrays": "uint8arrays@3.1.1", + "varint": "varint@6.0.0" + } + }, + "multiformats@9.9.0": { + "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==", + "dependencies": {} + }, + "node-domexception@1.0.0": { + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "dependencies": {} + }, + "node-fetch@3.3.2": { + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dependencies": { + "data-uri-to-buffer": "data-uri-to-buffer@4.0.1", + "fetch-blob": "fetch-blob@3.2.0", + "formdata-polyfill": "formdata-polyfill@4.0.10" + } + }, + "pkijs@3.2.4": { + "integrity": "sha512-Et9V5QpvBilPFgagJcaKBqXjKrrgF5JL2mSDELk1vvbOTt4fuBhSSsGn9Tcz0TQTfS5GCpXQ31Whrpqeqp0VRg==", + "dependencies": { + "@noble/hashes": "@noble/hashes@1.5.0", + "asn1js": "asn1js@3.0.5", + "bytestreamjs": "bytestreamjs@2.0.1", + "pvtsutils": "pvtsutils@1.3.5", + "pvutils": "pvutils@1.1.3", + "tslib": "tslib@2.7.0" + } + }, + "pvtsutils@1.3.5": { + "integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==", + "dependencies": { + "tslib": "tslib@2.7.0" + } + }, + "pvutils@1.1.3": { + "integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==", + "dependencies": {} + }, + "rdf-canonize@3.4.0": { + "integrity": "sha512-fUeWjrkOO0t1rg7B2fdyDTvngj+9RlUyL92vOdiB7c0FPguWVsniIMjEtHH+meLBO9rzkUlUzBVXgWrjI8P9LA==", + "dependencies": { + "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": {} + }, + "uint8arrays@3.1.1": { + "integrity": "sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg==", + "dependencies": { + "multiformats": "multiformats@9.9.0" + } + }, + "undici@5.28.4": { + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "dependencies": { + "@fastify/busboy": "@fastify/busboy@2.1.1" + } + }, + "uri-template-router@0.0.16": { + "integrity": "sha512-kvIuR8BtfL/VXFCM5hA7kjfYBdxMKQMmjOOA2zPUR1Xy7K+aVF2cVWMDaQEa2O74WN7zMloyvvmYjNJ38fVUew==", + "dependencies": {} + }, + "url-template@3.1.1": { + "integrity": "sha512-4oszoaEKE/mQOtAmdMWqIRHmkxWkUZMnXFnjQ5i01CuRSK3uluxcH1MRVVVWmhlnzT1SCDfKxxficm2G37qzCA==", + "dependencies": {} + }, + "varint@6.0.0": { + "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==", + "dependencies": {} + }, + "web-streams-polyfill@3.3.3": { + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "dependencies": {} + }, + "yallist@4.0.0": { + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dependencies": {} + } + } + }, + "remote": {}, + "workspace": { + "dependencies": [ + "jsr:@fedify/fedify@^1.0.2", + "jsr:@fedify/redis@^0.2.0", + "jsr:@hongminhee/x-forwarded-fetch@^0.2.0", + "jsr:@logtape/logtape@^0.4.3", + "jsr:@std/dotenv@^0.225.2", + "npm:ioredis@^5.4.1" + ] + } +} diff --git a/fedishoop/federation.ts b/fedishoop/federation.ts new file mode 100644 index 0000000..e703ffd --- /dev/null +++ b/fedishoop/federation.ts @@ -0,0 +1,21 @@ +import { createFederation, Person } from "@fedify/fedify"; +import { getLogger } from "@logtape/logtape"; +import { RedisKvStore, RedisMessageQueue } from "@fedify/redis"; +import { Redis } from "ioredis"; + +const logger = getLogger("fedishoop"); + +const federation = createFederation({ + kv: new RedisKvStore(new Redis(Deno.env.get("REDIS_URL"))), + queue: new RedisMessageQueue(() => new Redis(Deno.env.get("REDIS_URL"))), +}); + +federation.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => { + return new Person({ + id: ctx.getActorUri(identifier), + preferredUsername: identifier, + name: identifier, + }); +}); + +export default federation; diff --git a/fedishoop/logging.ts b/fedishoop/logging.ts new file mode 100644 index 0000000..547e3ff --- /dev/null +++ b/fedishoop/logging.ts @@ -0,0 +1,13 @@ +import { configure, getConsoleSink } from "@logtape/logtape"; + +await configure({ + sinks: { + console: getConsoleSink(), + }, + filters: {}, + loggers: [ + { category: "fedishoop", level: "debug", sinks: ["console"] }, + { category: "fedify", level: "info", sinks: ["console"] }, + { category: "logtape", level: "warning", sinks: ["console"] }, + ], +}); diff --git a/fedishoop/main.ts b/fedishoop/main.ts new file mode 100644 index 0000000..c54396d --- /dev/null +++ b/fedishoop/main.ts @@ -0,0 +1,13 @@ +import "@std/dotenv/load"; +import { behindProxy } from "@hongminhee/x-forwarded-fetch"; +import federation from "./federation.ts"; +import "./logging.ts"; + +Deno.serve( + { + port: 8000, + onListen: ({ port, hostname }) => + console.log("Server started at http://" + hostname + ":" + port) + }, + behindProxy((req) => federation.fetch(req, { contextData: undefined })), +); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..81b6d41 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "FediShoop", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..6e4bf94 --- /dev/null +++ b/shell.nix @@ -0,0 +1,6 @@ +{ pkgs ? import {}}: + pkgs.mkShellNoCC { + packages = with pkgs; [ + deno + ]; +}