-
Notifications
You must be signed in to change notification settings - Fork 10
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
3ac2c7c
commit f2880c6
Showing
1 changed file
with
28 additions
and
0 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,28 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
import arcjet, { rateLimit, withArcjet } from "@arcjet/next"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export const config = { | ||
runtime: "edge", | ||
}; | ||
|
||
const aj = arcjet({ | ||
// mark | ||
key: "ajkey_yourkey", | ||
rules: [ | ||
rateLimit({ | ||
mode: "LIVE", | ||
// Limiting by ip.src is the default if not specified | ||
//characteristics: ["ip.src"], | ||
window: "1m", | ||
max: 1, | ||
timeout: "10m", | ||
}), | ||
], | ||
}); | ||
|
||
export default withArcjet(aj, async function handler(req: NextRequest) { | ||
return NextResponse.json({ | ||
message: "Hello world", | ||
}); | ||
}); |