Skip to content

Commit

Permalink
Update bun.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
perkinsjr authored Oct 9, 2024
1 parent e6d5260 commit 755a5f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/docs/quickstart/ratelimiting/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ duration = amount of time to limit against for example "30s"
**/
const limiter = new Ratelimit({
namespace: "bun-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
namespace: "bun-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
})

const server = Bun.serve({
async fetch(req) {
const identifier = req.getUserId() // or ip or anything else you want

const ratelimit = await unkey.limit(identifier)
const ratelimit = await limiter.limit(identifier)
if (!ratelimit.success){
return Response("try again later", { status: 429 })
}
Expand Down

0 comments on commit 755a5f3

Please sign in to comment.