{"action":"created","issue":{"url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/65","repository_url":"https://api.github.com/repos/nfriedly/express-rate-limit","labels_url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/65/comments","events_url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/65/events","html_url":"https://github.com/nfriedly/express-rate-limit/issues/65","id":283681702,"node_id":"MDU6SXNzdWUyODM2ODE3MDI=","number":65,"title":"TypeScript support","user":{"login":"SimonSchick","id":3259089,"node_id":"MDQ6VXNlcjMyNTkwODk=","avatar_url":"https://avatars3.githubusercontent.com/u/3259089?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonSchick","html_url":"https://github.com/SimonSchick","followers_url":"https://api.github.com/users/SimonSchick/followers","following_url":"https://api.github.com/users/SimonSchick/following{/other_user}","gists_url":"https://api.github.com/users/SimonSchick/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSchick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSchick/subscriptions","organizations_url":"https://api.github.com/users/SimonSchick/orgs","repos_url":"https://api.github.com/users/SimonSchick/repos","events_url":"https://api.github.com/users/SimonSchick/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSchick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2017-12-20T20:11:53Z","updated_at":"2018-12-23T08:13:11Z","closed_at":null,"author_association":"NONE","body":"I wrote some typings for this lib, figured I would post them here.\r\n\r\n```typescript\r\ndeclare module 'express-rate-limit' {\r\n  import { RequestHandler, Request, Response } from 'express';\r\n  namespace limit {\r\n    interface Store {\r\n      /**\r\n       * Increments the value in the underlying store for the given key.\r\n       */\r\n      incr(key: string, cb: (err?: Error, hits?: number) => void): void;\r\n      /**\r\n       * Decrements the value in the underlying store for the given key.\r\n       * Used only and must be implemented when skipFailedRequests is true.\r\n       */\r\n      decrement?(key: string): void;\r\n      /**\r\n       * Resets a value with the given key.\r\n       */\r\n      resetKey(key: string): void;\r\n    }\r\n\r\n    interface RateLimitHandler extends RequestHandler {\r\n      /**\r\n       * Proxy function that calls `Store.resetKey`\r\n       */\r\n      resetKey(key: string): void;\r\n    }\r\n\r\n    interface RateLimitOptions {\r\n      /**\r\n       * how long to keep records of requests in memory.\r\n       * Is not used for actually checking anything if `store` is set.\r\n       * Will be used when `headers` is enabled.\r\n       */\r\n      windowMs?: number;\r\n      /**\r\n       * how many requests to allow through before starting to delay responses\r\n       */\r\n      delayAfter?: number;\r\n      /**\r\n       * base delay applied to the response - multiplied by number of recent hits for the same key.\r\n       */\r\n      delayMs?: number;\r\n      /**\r\n       * max number of recent connections during `window` milliseconds before sending a 429 response\r\n       */\r\n      max?: number;\r\n      /**\r\n       * Message to be send on ratelimit hit.\r\n       * Ignored if `handler` is set.\r\n       * If request is `json`, the message will be send as `{ message: MSGOBJECT }`\r\n       * If request is `html`, the message will not be altered.\r\n       * Default:'Too many requests, please try again later.',\r\n       */\r\n      message?: string | object;\r\n      /**\r\n       * Status code to be send on ratelimit hit.\r\n       * Ignored if `handler` is set.\r\n       * Defaults to 429 (RFC)\r\n       */\r\n      statusCode?: number;\r\n      /**\r\n       * Send custom rate limit header with limit and remaining.\r\n       * Ignored if `handler` is set.\r\n       * Defaults to true.\r\n       */\r\n      headers?: boolean;\r\n      /**\r\n       * Do not count failed requests (status >= 400).\r\n       * Store must implement `decrement` method for this to work.\r\n       * Defaults to false.\r\n       */\r\n      skipFailedRequests?: boolean;\r\n      /**\r\n       * allows to create custom keys.\r\n       * Defaults to request ip.\r\n       */\r\n      keyGenerator?(req: Request, res: Response): string;\r\n      /**\r\n       * allows to skip certain requests.\r\n       * Defaults to skipping none.\r\n       */\r\n      skip?(req: Request, res: Response): boolean;\r\n      /**\r\n       * allows to skip certain requests.\r\n       * Defaults to skipping none.\r\n       */\r\n      skip?(req: Request, res: Response): boolean;\r\n      /**\r\n       * Can be overriden to implement custom response behaviour.\r\n       * See other options to see what this does.\r\n       */\r\n      handler?: RequestHandler;\r\n      /**\r\n       * Called each time the limit is reached.\r\n       * You can use it to debug/log.\r\n       * Defaults to doing nothing.\r\n       */\r\n      onLimitReached?(req: Request, res: Response, opts: RateLimitOptions): void;\r\n\r\n      /**\r\n       * Store to use for ratelimiting.\r\n       * Defaults to in memory.\r\n       */\r\n      store?: Store;\r\n    }\r\n  }\r\n  function limit(options?: limit.RateLimitOptions): limit.RateLimitHandler;\r\n\r\n  export = limit;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/comments/449621221","html_url":"https://github.com/nfriedly/express-rate-limit/issues/65#issuecomment-449621221","issue_url":"https://api.github.com/repos/nfriedly/express-rate-limit/issues/65","id":449621221,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTYyMTIyMQ==","user":{"login":"andreGarvin","id":15004253,"node_id":"MDQ6VXNlcjE1MDA0MjUz","avatar_url":"https://avatars1.githubusercontent.com/u/15004253?v=4","gravatar_id":"","url":"https://api.github.com/users/andreGarvin","html_url":"https://github.com/andreGarvin","followers_url":"https://api.github.com/users/andreGarvin/followers","following_url":"https://api.github.com/users/andreGarvin/following{/other_user}","gists_url":"https://api.github.com/users/andreGarvin/gists{/gist_id}","starred_url":"https://api.github.com/users/andreGarvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreGarvin/subscriptions","organizations_url":"https://api.github.com/users/andreGarvin/orgs","repos_url":"https://api.github.com/users/andreGarvin/repos","events_url":"https://api.github.com/users/andreGarvin/events{/privacy}","received_events_url":"https://api.github.com/users/andreGarvin/received_events","type":"User","site_admin":false},"created_at":"2018-12-23T08:13:11Z","updated_at":"2018-12-23T08:13:11Z","author_association":"NONE","body":"https://github.com/nfriedly/express-rate-limit/pull/119"}}
{"actor":{"display_login":"andreGarvin"}}