-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26213d9
commit 1148023
Showing
10 changed files
with
139 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default defineEventHandler(async (event) => { | ||
const { cloudflare } = event.context | ||
|
||
// FIXME: THIS IS NOT RECOMMENDED. BUT I WILL USE IT FOR NOW | ||
// Not recommended: many users may share a single IP, especially on mobile networks | ||
// or when using privacy-enabling proxies | ||
const ipAddress = getHeader(event, 'CF-Connecting-IP') ?? '' | ||
|
||
const { success } = await // KILL YOURSELF | ||
(cloudflare.env as unknown as Env).RATE_LIMITER.limit({ | ||
key: ipAddress | ||
}) | ||
|
||
if (!success) { | ||
throw createError('Failure – global rate limit exceeded') | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"extends": "../.nitro/types/tsconfig.json" | ||
"extends": "../.nitro/types/tsconfig.json", | ||
"compilerOptions": { | ||
"types": [ | ||
"@cloudflare/workers-types" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Generated by Wrangler by running `wrangler types api/worker-configuration.d.ts` | ||
|
||
interface Env { | ||
STORAGE: KVNamespace; | ||
RATE_LIMITER: RateLimit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
> [!NOTE] | ||
> The website is no longer getting new features. It is now in maintenance mode. Please do not open issues or PRs. | ||
This is the website source code to be used with [VitePress](https://vitepress.dev/). | ||
|
||
Licensed under the Apache License v2.0, see [LICENSE](./LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.