Ratelimiting
Express
Ratelimiting endpoints with Express
Prerequisites
- Created your Unkey account
- Created an Unkey root key with
ratelimit.*.create_namespace
andratelimit.*.limit
permissions.
Creating an express server
1
Create express application
First run the following:
Then update your package.json to have the following
2
Install
Now install the @unkey/ratelimit
package
3
Add Root Key to env
Add your root key to your .env
file
4
Creating the server
Create a file called server.ts
and add the following code
server.ts
5
Running the server
6
Try it out
You will need to curl a few times to see the ratelimiting error. Once you do, you, you will need to wait to perform the action again.
What is next?
Now that you’ve seen the power of Unkey, check out some resources below to continue your journey.