diff --git a/indiekit.config.mjs b/indiekit.config.mjs index 4edb0605..030d7885 100644 --- a/indiekit.config.mjs +++ b/indiekit.config.mjs @@ -129,6 +129,28 @@ const webmentionsProxyCacheTtlRaw = Number.parseInt( const webmentionsProxyCacheTtl = Number.isFinite(webmentionsProxyCacheTtlRaw) ? webmentionsProxyCacheTtlRaw : 60; +const commentsMountPath = process.env.COMMENTS_MOUNT_PATH || "/comments"; +const commentsRateLimitPerHourRaw = Number.parseInt( + process.env.COMMENTS_RATE_LIMIT_PER_HOUR || "5", + 10, +); +const commentsRateLimitPerHour = Number.isFinite(commentsRateLimitPerHourRaw) + ? commentsRateLimitPerHourRaw + : 5; +const commentsRateLimitPerDayRaw = Number.parseInt( + process.env.COMMENTS_RATE_LIMIT_PER_DAY || "20", + 10, +); +const commentsRateLimitPerDay = Number.isFinite(commentsRateLimitPerDayRaw) + ? commentsRateLimitPerDayRaw + : 20; +const commentsMaxLengthRaw = Number.parseInt( + process.env.COMMENTS_MAX_LENGTH || "2000", + 10, +); +const commentsMaxLength = Number.isFinite(commentsMaxLengthRaw) + ? commentsMaxLengthRaw + : 2000; const authorName = process.env.AUTHOR_NAME || ""; const authorBio = process.env.AUTHOR_BIO || ""; const authorAvatar = (() => { @@ -269,6 +291,7 @@ export default { "@rmdes/indiekit-endpoint-webmention-sender", "@rmdes/indiekit-endpoint-homepage", "@rmdes/indiekit-endpoint-conversations", + "@rmdes/indiekit-endpoint-comments", "@rmdes/indiekit-endpoint-funkwhale", "@rmdes/indiekit-endpoint-lastfm", "@rmdes/indiekit-endpoint-podroll", @@ -324,6 +347,14 @@ export default { "@rmdes/indiekit-endpoint-conversations": { mountPath: "/conversations", }, + "@rmdes/indiekit-endpoint-comments": { + mountPath: commentsMountPath, + rateLimit: { + perHour: commentsRateLimitPerHour, + perDay: commentsRateLimitPerDay, + }, + maxLength: commentsMaxLength, + }, "@rmdes/indiekit-endpoint-funkwhale": { mountPath: "/funkwhale", instanceUrl: funkwhaleInstance, diff --git a/package-lock.json b/package-lock.json index ab79c12b..7ddb1335 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@indiekit/post-type-repost": "^1.0.0-beta.25", "@indiekit/store-github": "^1.0.0-beta.25", "@rmdes/indiekit-endpoint-activitypub": "^2.8.0", + "@rmdes/indiekit-endpoint-comments": "^1.0.0", "@rmdes/indiekit-endpoint-conversations": "^2.1.6", "@rmdes/indiekit-endpoint-funkwhale": "^1.0.11", "@rmdes/indiekit-endpoint-github": "^1.2.3", @@ -2351,6 +2352,20 @@ "@indiekit/frontend": "^1.0.0-beta.25" } }, + "node_modules/@rmdes/indiekit-endpoint-comments": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@rmdes/indiekit-endpoint-comments/-/indiekit-endpoint-comments-1.0.0.tgz", + "integrity": "sha512-uW2nclae6l7XY7udM8yey2PnTCxdn9It8VChpmddwhQAn233EsCKU5KILYyuWFP8OMcm8sdD1o9rq8NqIdLK/A==", + "license": "MIT", + "dependencies": { + "@indiekit/error": "^1.0.0-beta.25", + "@indiekit/frontend": "^1.0.0-beta.25", + "cookie-parser": "^1.4.6" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@rmdes/indiekit-endpoint-conversations": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/@rmdes/indiekit-endpoint-conversations/-/indiekit-endpoint-conversations-2.1.6.tgz", @@ -3860,6 +3875,25 @@ "integrity": "sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==", "license": "MIT" }, + "node_modules/cookie-parser": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-parser/node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, "node_modules/cookie-session": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-2.1.1.tgz", diff --git a/package.json b/package.json index bf87e2dd..63fd95b2 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@indiekit/post-type-repost": "^1.0.0-beta.25", "@indiekit/store-github": "^1.0.0-beta.25", "@rmdes/indiekit-endpoint-activitypub": "^2.8.0", + "@rmdes/indiekit-endpoint-comments": "^1.0.0", "@rmdes/indiekit-endpoint-conversations": "^2.1.6", "@rmdes/indiekit-endpoint-funkwhale": "^1.0.11", "@rmdes/indiekit-endpoint-github": "^1.2.3",