ソースを参照

feat: increase rate limit & update deps

Sven 1 年間 前
コミット
11e3f32b71
6 ファイル変更308 行追加286 行削除
  1. 7 1
      CHANGELOG.md
  2. 2 2
      README.md
  3. 287 276
      package-lock.json
  4. 3 3
      package.json
  5. 7 0
      src/constants.ts
  6. 2 4
      src/server.ts

+ 7 - 1
CHANGELOG.md

@@ -1,5 +1,6 @@
 ## Version History:
-- **[1.3.1](#v131)**
+- **[1.3.2](#v132)**
+- [1.3.1](#v131)
 - [1.3.0](#v130)
 - [1.2.0](#v120)
 - [1.1.1](#v111)
@@ -10,6 +11,11 @@
 
 <br><br>
 
+### v1.3.2
+- Increased ratelimit budget from 5 requests in 15 seconds to 25 requests in 30 seconds
+
+<br>
+
 ### v1.3.1
 - Fixed inconsistent `error` property when no translations are found
 - Added support for preflight through an OPTIONS request

+ 2 - 2
README.md

@@ -14,13 +14,13 @@ To download it and test locally, hover over the collection, click the three-dot-
 <br><br>
 
 ## Base URL:
-I host a public instance on this URL:
+I host a public instance on this base URL:
 ```
 https://api.sv443.net/geniurl/
 ```
 
 <sub>
-Note that this instance is rate limited to 5 requests within 15 seconds per unique client.
+Note: this instance is rate limited to 25 requests within a 30 second timeframe.
 </sub>
 
 <br><br>

ファイルの差分が大きいため隠しています
+ 287 - 276
package-lock.json


+ 3 - 3
package.json

@@ -1,6 +1,6 @@
 {
   "name": "geniurl",
-  "version": "1.3.1",
+  "version": "1.3.2",
   "description": "Simple JSON and XML REST API to search for song metadata, the lyrics URL and lyrics translations on genius.com",
   "main": "src/index.ts",
   "scripts": {
@@ -37,7 +37,7 @@
     "cors": "^2.8.5",
     "express": "^4.17.3",
     "fuse.js": "^6.6.2",
-    "helmet": "^6.0.1",
+    "helmet": "^7.0.0",
     "js2xmlparser": "^5.0.0",
     "kleur": "^4.1.4",
     "nanoid": "^3.3.4",
@@ -49,7 +49,7 @@
     "@types/compression": "^1.7.2",
     "@types/cors": "^2.8.12",
     "@types/express": "^4.17.14",
-    "@types/node": "^18.11.3",
+    "@types/node": "^20.3.3",
     "@types/tcp-port-used": "^1.0.1",
     "@typescript-eslint/eslint-plugin": "^5.48.1",
     "@typescript-eslint/parser": "^5.48.1",

+ 7 - 0
src/constants.ts

@@ -1,3 +1,10 @@
+import type { IRateLimiterOptions } from "rate-limiter-flexible";
+
+export const rateLimitOptions: IRateLimiterOptions = {
+    points: 25,
+    duration: 30,
+};
+
 /** Set of all supported [ISO 639-1 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) */
 export const langCodes = new Set<string>(["aa","ab","ae","af","ak","am","an","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","io","is","it","iu","ja","jv","ka","kg","ki","kj","kk","kl","km","kn","ko","kr","ks","ku","kv","kw","ky","la","lb","lg","li","ln","lo","lt","lu","lv","mg","mh","mi","mk","ml","mn","mr","ms","mt","my","na","nb","nd","ne","ng","nl","nn","no","nr","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt","qu","rm","rn","ro","ru","rw","sa","sc","sd","se","sg","si","sk","sl","sm","sn","so","sq","sr","ss","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh","zu"]);
 

+ 2 - 4
src/server.ts

@@ -10,6 +10,7 @@ import packageJson from "../package.json";
 import { error } from "./error";
 import { initRouter } from "./routes";
 import { respond } from "./utils";
+import { rateLimitOptions } from "./constants";
 
 const { env } = process;
 const app = express();
@@ -31,10 +32,7 @@ if(env.NODE_ENV?.toLowerCase() === "production")
 
 app.disable("x-powered-by");
 
-const rateLimiter = new RateLimiterMemory({
-    points: 5,
-    duration: 15,
-});
+const rateLimiter = new RateLimiterMemory(rateLimitOptions);
 
 const authTokens = getAuthTokens();
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません