From 93278524ef21a17242e9d23a07fdb4b661a3d0f5 Mon Sep 17 00:00:00 2001 From: echo8 Date: Sun, 22 Dec 2024 21:06:01 +0900 Subject: [PATCH] change templating lib --- Dockerfile.server | 1 + package-lock.json | 315 ++++++++++++++++------------------- src/server/package.json | 3 +- src/server/src/index.ts | 2 + src/server/src/routes.ts | 27 +-- src/server/src/util/view.ts | 12 -- src/server/views/snippet.ejs | 19 +++ 7 files changed, 173 insertions(+), 206 deletions(-) delete mode 100644 src/server/src/util/view.ts create mode 100644 src/server/views/snippet.ejs diff --git a/Dockerfile.server b/Dockerfile.server index 77eca85..1ff9176 100644 --- a/Dockerfile.server +++ b/Dockerfile.server @@ -27,6 +27,7 @@ COPY src/server/package.json ./src/server/package.json RUN npm ci --omit=dev COPY --from=builder /app/src/server/dist ./dist +COPY --from=builder /app/src/server/views ./views EXPOSE 443 CMD [ "node", "dist/index.js" ] diff --git a/package-lock.json b/package-lock.json index 5d784f4..fa52e8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1767,17 +1767,6 @@ "resolved": "https://registry.npmjs.org/@pandacss/is-valid-prop/-/is-valid-prop-0.41.0.tgz", "integrity": "sha512-BE6h6CsJk14ugIRrsazJtN3fcg+KDFRat1Bs93YFKH6jd4DOb1yUyVvC70jKqPVvg70zEcV8acZ7VdcU5TLu+w==" }, - "node_modules/@preact/signals-core": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@preact/signals-core/-/signals-core-1.8.0.tgz", - "integrity": "sha512-OBvUsRZqNmjzCZXWLxkZfhcgT+Fk8DDcT/8vD6a1xhDemodyy87UJRJfASMuSD8FaAIeGgGm85ydXhm7lr4fyA==", - "license": "MIT", - "optional": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/preact" - } - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.28.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.28.0.tgz", @@ -2264,6 +2253,13 @@ "@types/ms": "*" } }, + "node_modules/@types/ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-nv+GSx77ZtXiJzwKdsASqi+YQ5Z7vwHsTP0JY2SiQgjGckkBRKZnk8nIM+7oUZ1VCtuTz0+By4qVR7fqzp/Dfg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -2573,22 +2569,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/@webreflection/signal": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@webreflection/signal/-/signal-2.1.2.tgz", - "integrity": "sha512-0dW0fstQQkIt588JwhDiPS4xgeeQcQnBHn6MVInrBzmFlnLtzoSJL9G7JqdAlZVVi19tfb8R1QisZIT31cgiug==", - "license": "ISC", - "optional": true - }, - "node_modules/@webreflection/uparser": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@webreflection/uparser/-/uparser-0.4.0.tgz", - "integrity": "sha512-kAFWUEw5eool295y01VDr+DOsyog6lURX9l288JCJAD2gxc0tFk34dYaAi6O3BbJyfSoncVEV+nw87bsssdppQ==", - "license": "MIT", - "dependencies": { - "domconstants": "^1.1.6" - } - }, "node_modules/@zag-js/accordion": { "version": "0.77.1", "resolved": "https://registry.npmjs.org/@zag-js/accordion/-/accordion-0.77.1.tgz", @@ -3514,6 +3494,12 @@ "node": ">=12" } }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -3600,7 +3586,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, "license": "MIT" }, "node_modules/base64-js": { @@ -3735,7 +3720,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -4141,7 +4125,6 @@ "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, "license": "MIT" }, "node_modules/content-disposition": { @@ -4265,12 +4248,6 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", "license": "MIT" }, - "node_modules/custom-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/custom-function/-/custom-function-2.0.0.tgz", - "integrity": "sha512-2OPHkZzq3mK1nWpJqWWkGD6Z+0AajNeIxmXl+MRVL8Vysjjf5tf9B5mo713/X2khEwBn/3BKQ7NphpP1vpVKug==", - "license": "MIT" - }, "node_modules/data-view-buffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.1.tgz", @@ -4483,67 +4460,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domconstants": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/domconstants/-/domconstants-1.1.6.tgz", - "integrity": "sha512-CuaDrThJ4VM+LyZ4ax8n52k0KbLJZtffyGkuj1WhpTRRcSfcy/9DfOBa68jenhX96oNUTunblSJEUNC4baFdmQ==", - "license": "ISC" - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "BSD-2-Clause" - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "license": "BSD-2-Clause", - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "license": "BSD-2-Clause", - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -4562,6 +4478,21 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "license": "MIT" }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/electron-to-chromium": { "version": "1.5.67", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.67.tgz", @@ -4587,18 +4518,6 @@ "once": "^1.4.0" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/envalid": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/envalid/-/envalid-8.0.0.tgz", @@ -5004,6 +4923,36 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "license": "MIT" }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -5186,12 +5135,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gc-hook": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/gc-hook/-/gc-hook-0.4.1.tgz", - "integrity": "sha512-uiF+uUftDVLr+VRdudsdsT3/LQYnv2ntwhRH964O7xXDI57Smrek5olv75Wb8Nnz6U+7iVTRXsBlxKcsaDTJTQ==", - "license": "ISC" - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -5472,12 +5415,6 @@ "dev": true, "license": "ISC" }, - "node_modules/html-escaper": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz", - "integrity": "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==", - "license": "MIT" - }, "node_modules/html-url-attributes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", @@ -5488,25 +5425,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/htmlparser2": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", - "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.1.0", - "entities": "^4.5.0" - } - }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -6097,6 +6015,94 @@ "integrity": "sha512-yLEMkBbLZTlVQqOnQ4FiMujR6T4DEcCb1xizmvXS+OxuhwcbtynoosRzdMA69zZCShCNAbi+gJ71FxZBBXx1SA==", "license": "MIT" }, + "node_modules/jake": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz", + "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==", + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jake/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/jake/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/jake/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/jake/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/jake/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jake/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jose": { "version": "5.9.6", "resolved": "https://registry.npmjs.org/jose/-/jose-5.9.6.tgz", @@ -7199,7 +7205,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -9323,31 +9328,6 @@ "node": ">=14.17" } }, - "node_modules/udomdiff": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/udomdiff/-/udomdiff-1.1.2.tgz", - "integrity": "sha512-v+Z8Jal+GtmKGtJ34GIQlCJAxrDt9kbjpNsNvYoAXFyr4gNfWlD4uJJuoNNu/0UTVaKvQwHaSU095YDl71lKPw==", - "license": "ISC" - }, - "node_modules/uhtml": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/uhtml/-/uhtml-4.7.0.tgz", - "integrity": "sha512-3j0YIvbu863FB27mwnuLcKK0zPsHVQWwUs/GFanVz/QSwsItT/lOcGKmIdpqlcfWpYBCBoMEdfK0vIN/P2kCmg==", - "license": "MIT", - "dependencies": { - "@webreflection/uparser": "^0.4.0", - "custom-function": "^2.0.0", - "domconstants": "^1.1.6", - "gc-hook": "^0.4.1", - "html-escaper": "^3.0.3", - "htmlparser2": "^9.1.0", - "udomdiff": "^1.1.2" - }, - "optionalDependencies": { - "@preact/signals-core": "^1.8.0", - "@webreflection/signal": "^2.1.2" - } - }, "node_modules/uint8arrays": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz", @@ -10463,13 +10443,13 @@ "compression": "^1.7.5", "cors": "^2.8.5", "dotenv": "^16.4.5", + "ejs": "^3.1.10", "envalid": "^8.0.0", "express": "^4.21.1", "iron-session": "^8.0.2", "kysely": "^0.27.4", "multiformats": "^13.3.1", "pino": "^9.5.0", - "uhtml": "^4.7.0", "zod": "^3.23.8" }, "devDependencies": { @@ -10477,6 +10457,7 @@ "@types/better-sqlite3": "^7.6.12", "@types/compression": "^1.7.5", "@types/cors": "^2.8.17", + "@types/ejs": "^3.1.5", "@types/express": "^4.17.21", "@types/node": "^22.9.3", "prettier": "3.3.3", diff --git a/src/server/package.json b/src/server/package.json index 8abb3cb..9b34894 100644 --- a/src/server/package.json +++ b/src/server/package.json @@ -29,13 +29,13 @@ "compression": "^1.7.5", "cors": "^2.8.5", "dotenv": "^16.4.5", + "ejs": "^3.1.10", "envalid": "^8.0.0", "express": "^4.21.1", "iron-session": "^8.0.2", "kysely": "^0.27.4", "multiformats": "^13.3.1", "pino": "^9.5.0", - "uhtml": "^4.7.0", "zod": "^3.23.8" }, "devDependencies": { @@ -43,6 +43,7 @@ "@types/better-sqlite3": "^7.6.12", "@types/compression": "^1.7.5", "@types/cors": "^2.8.17", + "@types/ejs": "^3.1.5", "@types/express": "^4.17.21", "@types/node": "^22.9.3", "prettier": "3.3.3", diff --git a/src/server/src/index.ts b/src/server/src/index.ts index d195b3b..ddc508e 100644 --- a/src/server/src/index.ts +++ b/src/server/src/index.ts @@ -22,6 +22,8 @@ const run = async () => { const jetstream = createJetStream(ctx); + app.set("view engine", "ejs"); + app.use( cors({ origin: env.isProduction diff --git a/src/server/src/routes.ts b/src/server/src/routes.ts index 637d5a3..f399b66 100644 --- a/src/server/src/routes.ts +++ b/src/server/src/routes.ts @@ -2,16 +2,12 @@ import express from "express"; import { initTRPC, TRPCError } from "@trpc/server"; import { z } from "zod"; import { IronSession } from "iron-session"; -import pino from "pino"; import { Agent } from "@atproto/api"; import { AppContext, Session, SnippetType, SnippetSchema } from "./types"; import { createTRPCContext } from "./context"; import { isDid } from "@atproto/did"; -import { page, html } from "./util/view"; import { env } from "./util/env"; -const logger = pino({ name: "router" }); - const expressHandler = (fn: express.Handler) => async ( @@ -56,28 +52,7 @@ export const createExpressRouter = (ctx: AppContext) => { const snippet = await ctx.snippetService.get(did, rkey); if (snippet) { const url = `${env.PUBLIC_URL}/user/${snippet.authorDid}/snippet/${snippet.rkey}`; - return res.type("html").send( - page( - html` - - ${snippet.title} - - - - - - - - - - Snippet metadata for bots. - - ` - ) - ); + return res.render("snippet", { snippet: snippet, url: url }); } } return res.status(404).send(); diff --git a/src/server/src/util/view.ts b/src/server/src/util/view.ts deleted file mode 100644 index 9d7b27a..0000000 --- a/src/server/src/util/view.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-ignore -import ssr from 'uhtml/ssr' -import type initSSR from 'uhtml/types/init-ssr' -import type { Hole } from 'uhtml/types/keyed' - -export type { Hole } - -export const { html }: ReturnType = ssr() - -export function page(hole: Hole) { - return `\n${hole.toDOM().toString()}` -} diff --git a/src/server/views/snippet.ejs b/src/server/views/snippet.ejs new file mode 100644 index 0000000..0f1e0ce --- /dev/null +++ b/src/server/views/snippet.ejs @@ -0,0 +1,19 @@ + + + + <%=snippet.title%> + + + + + + + + + + Snippet metadata for bots. + +