Explorar o código

feat: lower rate limit budget

Sv443 hai 5 meses
pai
achega
3126312abb
Modificáronse 4 ficheiros con 51 adicións e 28 borrados
  1. 7 21
      CHANGELOG.md
  2. 41 4
      README.md
  3. 2 2
      src/constants.ts
  4. 1 1
      src/songData.ts

+ 7 - 21
CHANGELOG.md

@@ -1,25 +1,11 @@
-## Version History:
-- **[1.3.3](#v133)**
-- [1.3.2](#v132)
-- [1.3.1](#v131)
-- [1.3.0](#v130)
-- [1.2.0](#v120)
-- [1.1.1](#v111)
-- [1.1.0](#v110)
-- [1.0.0](#v100)
-- [0.2.0](#v020)
-- [0.1.0](#v010)
-
-<br><br>
-
-<!-- ### v1.4.0
-**Breaking changes:**
-- Removed `?preferLang` parameter due to genius API not returning a song language anymore ([#20](https://github.com/Sv443/geniURL/issues/20))
-
-**Fixes:**
-- TODO: Fuzzy filtering is now much more accurate and direct matches will be preferred ([#17](https://github.com/Sv443/geniURL/issues/17))
+### v2.0.0
+**Features:**
+- Added `?redirect` parameter for automatic HTTP redirection instead of returning a JSON response ([#22](https://github.com/Sv443/geniURL/issues/22))
+**Changes:**
+- Removed fuzzy filtering and `?disableFuzzy` parameter altogether (to maybe be added back in the future as an opt-in feature) ([#24](https://github.com/Sv443/geniURL/issues/24))
+- Reduced ratelimit budget from 25 requests every 30 seconds to 20 requests
 
-<br> -->
+<br>
 
 ### v1.3.3
 **Changes:**

+ 41 - 4
README.md

@@ -3,9 +3,24 @@ Simple JSON and XML REST API to search for song metadata, the lyrics URL and lyr
 Authorization is not required and geniURL implements a fuzzy search that will greatly improve search results over the genius.com API.  
 Obtaining actual lyrics sadly isn't possible.  
   
-Like geniURL? Please consider [supporting the development ❤️](https://github.com/sponsors/Sv443)  
+Disclaimer: this project is not affiliated with or endorsed by Genius.  
   
-Disclaimer: this project is not affiliated with or endorsed by Genius.
+> [!NOTE]  
+> Like using geniURL for free?  
+> It's entirely reliant on donations so please consider [supporting the development ❤️](https://github.com/sponsors/Sv443)  
+
+<br>
+
+## Table of contents:
+- [Try it out](#try-it-out)
+- [Base URL](#base-url)
+- [Routes](#routes)
+    - [Search](#get-search)
+        - [Search (only top result)](#get-searchtop)
+    - [Translations](#get-translationssongid)
+    - [Associated Album](#get-albumsongid)
+- [Local setup](#local-setup)
+- [Legal stuff](#legal-stuff)
 
 <br><br>
 
@@ -21,7 +36,7 @@ I host a public instance on this base URL:
 https://api.sv443.net/geniurl/
 ```
 
-Note: this instance is rate limited to 25 requests within a 30 second timeframe.  
+Note: this instance is rate limited to 20 requests within a 30 second timeframe.  
 To always know how many requests you are able to send, refer to the response headers `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`
 
 
@@ -396,11 +411,33 @@ The structure of the XML data is similar to the shown JSON data.
 
 </details><br>
 
+<br><br>
+
+## Local setup:
+To set up geniURL locally, follow these steps:
+1. Have [Node.js](https://nodejs.org/) (current version) and npm installed
+2. Clone or download and extract this repository
+3. Run the command `npm i` in the project directory
+4. Copy `.env.template` to `.env` and fill in the required values  
+  The genius.com key can be obtained by [creating an API client here](https://genius.com/api-clients)
+5. Run the command `npm start` to start the server  
+  Alternatively, run `npm run dev` to start the server with nodemon for automatic restarts when the code is changed
+
+I recommend using a process manager like [PM2](https://pm2.keymetrics.io/) to keep the server running in the background, make it automatically restart on crashes and start on system boot.
+
+<br><br>
+
+## Legal stuff:
+This project is licensed under the [MIT License](./LICENSE.txt)  
+  
+The genius.com API is used to get the search results and song metadata. No actual lyrics are obtained.  
+This project is not affiliated with, sponsored or endorsed by genius.com.
+
 <br><br><br>
 
 <div align="center" style="text-align:center;">
 
 Made with ❤️ by [Sv443](https://sv443.net/)  
-If you like geniURL, please consider [supporting the development](https://github.com/sponsors/Sv443)
+If you like geniURL, please consider [supporting the development ❤️](https://github.com/sponsors/Sv443)
 
 </div>

+ 2 - 2
src/constants.ts

@@ -1,14 +1,14 @@
 import type { IRateLimiterOptions } from "rate-limiter-flexible";
 
 export const rateLimitOptions: IRateLimiterOptions = {
-  points: 25,
+  points: 20,
   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"]);
 
-/** Map of unicode variant characters and replacements used in normalizing fields before fuzzy filtering them */
+/** Map of unicode variant characters and replacements used in normalizing strings served by the genius API */
 export const charReplacements = new Map<string, string>([
   ["`´’︐︑ʻ", "'"],
   ["“”", "\""],

+ 1 - 1
src/songData.ts

@@ -104,7 +104,7 @@ export async function getMeta({
 
         if(!scoreMap[item.uuid])
           scoreMap[item.uuid] = score;
-        else
+        else if(typeof scoreMap[item.uuid] === "number") // @ts-ignore
           scoreMap[item.uuid] += score;
       });