{"id":13630701,"url":"https://github.com/dotcypress/micro-ratelimit","last_synced_at":"2025-03-17T05:32:24.665Z","repository":{"id":57296547,"uuid":"86734839","full_name":"dotcypress/micro-ratelimit","owner":"dotcypress","description":"Rate-limiting middleware for micro","archived":false,"fork":false,"pushed_at":"2018-10-04T16:45:56.000Z","size":7,"stargazers_count":74,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T18:27:04.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotcypress.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-30T18:22:08.000Z","updated_at":"2022-04-18T06:58:34.000Z","dependencies_parsed_at":"2022-09-07T03:21:28.306Z","dependency_job_id":null,"html_url":"https://github.com/dotcypress/micro-ratelimit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-ratelimit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-ratelimit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-ratelimit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotcypress%2Fmicro-ratelimit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotcypress","download_url":"https://codeload.github.com/dotcypress/micro-ratelimit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846984,"owners_count":20357297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:56.097Z","updated_at":"2025-03-17T05:32:23.811Z","avatar_url":"https://github.com/dotcypress.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Modules"],"sub_categories":["Middlewares"],"readme":"[![Build Status](https://img.shields.io/travis/dotcypress/micro-ratelimit.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/dotcypress/micro-ratelimit)\n[![NPM Version](https://img.shields.io/npm/v/micro-ratelimit.svg?style=flat-square)](https://www.npmjs.com/package/micro-ratelimit)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n\n# Micro Rate Limit\n\nRate-limiting middleware for [micro](https://github.com/zeit/micro).\n\n## Installation\n\n```js\n$ npm install micro-ratelimit\n```\n\n## Examples\n  \n```js\nconst rateLimit = require('micro-ratelimit')\n\nmodule.exports = rateLimit((req, res) =\u003e {\n  return 'Hello world'\n})\n\n```\n\n```js\nconst rateLimit = require('micro-ratelimit')\n\n// Limit example: 2 requests per 10 sec\nmodule.exports = rateLimit({ window: 10000, limit: 2, headers: true }, (req, res) =\u003e {\n  return 'Hello world'\n})\n\n```\n\n## API\n\n### Options\n\n* `window`: how long to keep records of requests in memory in ms (default: 1 second)\n* `limit`: max number of requests during window (default: 1)\n* `keyGenerator`: key generator function (req -\u003e client id)\n* `headers`: send rate limit headers (default: false)\n\nDefault implementation of `keyGenerator`:\n\n```js\nfunction keyGenerator (req) {\n  return req.headers['x-forwarded-for'] ||\n    req.connection.remoteAddress ||\n    req.socket.remoteAddress ||\n    req.connection.socket.remoteAddress\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotcypress%2Fmicro-ratelimit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotcypress%2Fmicro-ratelimit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotcypress%2Fmicro-ratelimit/lists"}