Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Express limit rate API request
Le Hong Son
Le Hong Son

Posted on

     

Express limit rate API request

Today I want to share my experience improve my backend node app with an express framework with a limited rate query user request.
demo API query

Hurry up!! let start

step 1: install module express-rate-limit

yarn add express-rate-limit

step 2: now, we need to import the library into our application

const rateLimit = require("express-rate-limit")

step 3: define variable inlude timer and number limit request

const limiter = rateLimit({
windowMs: 1 * 60 * 1000, // 15 minutes
max: 10 // limit each IP to 100 requests per windowMs
})

step 4: use limiter as middleware of expressjs

app.use(limiter);
alt text

Congratulation !! you finished improving your security rest API

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

learn and share knowledge about dev career
  • Location
    viet nam
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp