From 72b5d4539d600e1ad2de289719898f670eeb0b33 Mon Sep 17 00:00:00 2001 From: yasinpalizban Date: Mon, 17 Apr 2023 18:56:58 +0330 Subject: [PATCH] feat: Migrate To Typescript --- .editorconfig | 9 + .eslintignore | 1 + .eslintrc | 18 + .eslintrc.json | 5 - .gitignore | 83 +- .idea/inspectionProfiles/Project_Default.xml | 6 + .idea/modules.xml | 8 + .idea/request-ip-type.iml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 146 + .lintstagedrc.json | 5 + .prettierrc | 8 + .swcrc | 29 + .travis.yml | 9 - CHANGELOG.md | 261 + LICENSE.md | 20 + SECURITY.md | 21 + index.js | 16 - jest.config.js | 12 + package-lock.json | 13726 ++++++++++++++++ package.json | 38 +- src/in-memory-store.js | 30 - src/in-memory-store.ts | 27 + src/index.d.ts | 13 + src/index.ts | 14 + src/rate-limiter.js | 98 - src/rate-limiter.ts | 106 + src/redis-legacy-store.js | 43 - src/redis-legacy-store.ts | 53 + src/redis-store.js | 40 - src/redis-store.ts | 48 + ...-store.test.js => in-memory-store.test.ts} | 24 +- test/rate-limiter.test.js | 197 - test/rate-limiter.test.ts | 200 + ...ore.test.js => redis-legacy-store.test.ts} | 26 +- ...edis-store.test.js => redis-store.test.ts} | 26 +- tsconfig.json | 29 + yarn.lock | 4393 ----- 38 files changed, 14915 insertions(+), 4887 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc delete mode 100644 .eslintrc.json create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/request-ip-type.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 .lintstagedrc.json create mode 100644 .prettierrc create mode 100644 .swcrc delete mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 SECURITY.md delete mode 100644 index.js create mode 100644 jest.config.js create mode 100644 package-lock.json delete mode 100644 src/in-memory-store.js create mode 100644 src/in-memory-store.ts create mode 100644 src/index.d.ts create mode 100644 src/index.ts delete mode 100644 src/rate-limiter.js create mode 100644 src/rate-limiter.ts delete mode 100644 src/redis-legacy-store.js create mode 100644 src/redis-legacy-store.ts delete mode 100644 src/redis-store.js create mode 100644 src/redis-store.ts rename test/{in-memory-store.test.js => in-memory-store.test.ts} (57%) delete mode 100644 test/rate-limiter.test.js create mode 100644 test/rate-limiter.test.ts rename test/{redis-legacy-store.test.js => redis-legacy-store.test.ts} (59%) rename test/{redis-store.test.js => redis-store.test.ts} (59%) create mode 100644 tsconfig.json delete mode 100644 yarn.lock diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c6c8b36 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3e22129 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +/dist \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..206ab05 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,18 @@ +{ + "parser": "@typescript-eslint/parser", + "extends": ["prettier", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "rules": { + "@typescript-eslint/explicit-member-accessibility": 0, + "@typescript-eslint/explicit-function-return-type": 0, + "@typescript-eslint/no-parameter-properties": 0, + "@typescript-eslint/interface-name-prefix": 0, + "@typescript-eslint/explicit-module-boundary-types": 0, + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/ban-types": "off", + "@typescript-eslint/no-var-requires": "off" + } +} diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index a92ce48..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "parserOptions": { - "ecmaVersion": 6 - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 45c2d6e..c6bba59 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,11 @@ logs npm-debug.log* yarn-debug.log* yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids @@ -16,11 +21,12 @@ lib-cov # Coverage directory used by tools like istanbul coverage +*.lcov # nyc test coverage .nyc_output -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) @@ -29,15 +35,18 @@ bower_components # node-waf configuration .lock-wscript -# Compiled binary addons (http://nodejs.org/api/addons.html) +# Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ -# Typescript v1 declaration files -typings/ +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo # Optional npm cache directory .npm @@ -45,6 +54,15 @@ typings/ # Optional eslint cache .eslintcache +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + # Optional REPL history .node_repl_history @@ -54,8 +72,59 @@ typings/ # Yarn Integrity file .yarn-integrity -# dotenv environment variables file +# dotenv environment variable files .env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test -# IDE Specific -.idea +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..239f861 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/request-ip-type.iml b/.idea/request-ip-type.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/request-ip-type.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..c6a686c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "ASKED_ADD_EXTERNAL_FILES": "true", + "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "js.last.introduce.type": "LET", + "last_opened_file_path": "/home/hope/githup/express-limiter-type", + "node.js.detected.package.eslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "preferences.lookFeel", + "ts.external.directory.path": "/home/hope/githup/express-limiter-type/node_modules/typescript/lib", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + 1656522441219 + + + + + + + + + + + +