diff --git a/.vitepress/routes/index.post.ts b/.vitepress/routes/index.post.ts index b7f3cc785..1828f774e 100644 --- a/.vitepress/routes/index.post.ts +++ b/.vitepress/routes/index.post.ts @@ -7,6 +7,14 @@ export default defineEventHandler(async (event) => { FeedbackSchema.parseAsync ) const env = useRuntimeConfig(event) + const { pathname } = new URL(event.node.req.url) + + const { success } = await env.MY_RATE_LIMITER.limit({ key: pathname }) + if (!success) { + return new Response(`429 Failure – rate limit exceeded for ${pathname}`, { + status: 429 + }) + } let description = `${message}\n\n` if (page) description += `**Page:** \`${page}\`` diff --git a/package.json b/package.json index bf1f9cdbd..7329160b1 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,9 @@ "@iconify-json/carbon": "^1.1.28", "@iconify-json/heroicons-solid": "^1.1.11", "@iconify-json/twemoji": "^1.1.15", - "@taskylizard/eslint-config": "^1.1.1", "@types/fs-extra": "^11.0.4", "@types/node": "^20.11.15", "@types/nprogress": "^0.2.3", - "eslint": "^8.56.0", "prettier": "^3.2.4", "tailwindcss": "^3.4.4" } diff --git a/tsconfig.json b/tsconfig.json index a49a06c8a..b80a29a16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,32 @@ { - "extends": "./.nitro/types/tsconfig.json", - "compilerOptions": { - "verbatimModuleSyntax": true - }, - "include": ["./.vitepress/"] + "extends": "./.nitro/types/tsconfig.json" + // "compilerOptions": { + // "verbatimModuleSyntax": true, + // "baseUrl": ".", + // "module": "esnext", + // "target": "esnext", + // "lib": ["DOM", "ESNext"], + // "strict": true, + // "jsx": "preserve", + // "esModuleInterop": true, + // "skipLibCheck": true, + // "moduleResolution": "node", + // "resolveJsonModule": true, + // "noUnusedLocals": true, + // "strictNullChecks": true, + // "forceConsistentCasingInFileNames": true, + // "sourceMap": true, + // "isolatedModules": true + // }, + // "include": [ + // "**/*.vue", + // "**/*.tsx", + // "**/*.ts", + // ".vitepress/**/**/*.ts", + // ".vitepress/**/**/*.tsx", + // ".vitepress/**/**/*.vue" + // ], + // "exclude": ["**/node_modules/**", "dist/**"], + // "extensions": [".js", ".ts", ".tsx", ".jsx", ".vue"], + // "allowSyntheticDefaultImports": true } diff --git a/wrangler.toml b/wrangler.toml index 7258e6c00..a96167615 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -3,3 +3,9 @@ main = ".output/server/index.mjs" workers_dev = true account_id = "fe5d9bd14160b07939282e45f63eb5ad" compatibility_date = "2022-09-10" + +[[unsafe.bindings]] +name = "RATE_LIMITER" +type = "ratelimit" +namespace_id = "1001" +simple = { limit = 100, period = 30 }