Browse Source

docs: ?limit param

Sv443 4 months ago
parent
commit
cb456420fa

+ 10 - 6
www/.vuepress/config.ts

@@ -1,5 +1,6 @@
 import { join, dirname } from "node:path";
 import { fileURLToPath } from "node:url";
+import { readdirSync } from "node:fs";
 import { defineUserConfig } from "vuepress/cli";
 import { defaultTheme } from "@vuepress/theme-default";
 import { viteBundler } from "@vuepress/bundler-vite";
@@ -12,9 +13,12 @@ import { navbarEn, sidebarEn } from "./configs/index.js";
 
 const verMajor = Number(rootPkgJson.version.split(".")![0]);
 
-const customComponents = [
-  "ManualSearch",
-];
+const componentDir = join(dirname(fileURLToPath(import.meta.url)), "./components/");
+const componentNames = readdirSync(componentDir).map((p) => {
+  const fileNameParts = p.split("/")!.at(-1).split(".");
+  fileNameParts.pop();
+  return fileNameParts.join(".");
+});
 
 export default defineUserConfig({
   lang: "en-US",
@@ -22,7 +26,7 @@ export default defineUserConfig({
   title: "geniURL",
   description: "A simple JSON and XML REST API to search for song metadata, the lyrics URL and lyrics translations on genius.com",
   theme: defaultTheme({
-    logo: "https://vuejs.press/images/hero.png",
+    // logo: "https://vuejs.press/images/hero.png",
     navbar: navbarEn,
     sidebar: sidebarEn,
   }),
@@ -36,8 +40,8 @@ export default defineUserConfig({
       hostname: "https://api.sv443.net",
     }),
     registerComponentsPlugin({
-      components: customComponents.reduce((a, c) => {
-        a[c] = join(dirname(fileURLToPath(import.meta.url)), `./components/${c}.vue`);
+      components: componentNames.reduce((a, c) => {
+        a[c] = join(componentDir, `${c}.vue`);
         return a;
       }, {}),
     }),

+ 1 - 1
www/.vuepress/configs/navbar/en.ts

@@ -13,7 +13,7 @@ export const navbarEn: NavbarOptions = [
   },
   {
     text: "Try It",
-    link: "/docs/manual-search.md",
+    link: "/docs/try-it.md",
   },
   {
     text: "GitHub",

+ 1 - 1
www/.vuepress/configs/sidebar/en.ts

@@ -17,7 +17,7 @@ export const sidebarEn: SidebarOptions = {
     },
     {
       text: "Try It",
-      link: "/docs/manual-search.md",
+      link: "/docs/try-it.md",
     },
   ],
   /*'/advanced/': [

+ 0 - 20
www/docs/README.md

@@ -8,23 +8,3 @@ description: Get started with using geniURL to fetch lyrics metadata
 geniURL is a simple JSON and XML REST API to search for song metadata, the lyrics URL and lyrics translations on genius.com.  
 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.
-
-<br>
-
-## Base URL
-I host a public instance on this base URL:  
-```
-https://api.sv443.net/geniurl/v2/
-```
-
-<br>
-
-## Rate Limiting
-The public instance is rate limited to 25 requests within a 30 second timeframe.  
-To know how many requests you have sent and are still able to send, refer to the following headers that are attached to each response:
-| Name                    | Description                                                                                                     |
-| :---------------------- | :-------------------------------------------------------------------------------------------------------------- |
-| `Retry-After`           | Number of seconds you need to wait until being able to send another request.                                    |
-| `X-RateLimit-Reset`     | An [ISO 8601 UTC timestamp](https://en.wikipedia.org/wiki/ISO_8601) indicating when you can send more requests. |
-| `X-RateLimit-Limit`     | The total number of requests you can send per timeframe.                                                        |
-| `X-RateLimit-Remaining` | The requests you are still able to send in the current timeframe.                                               |

+ 30 - 4
www/docs/routes/README.md

@@ -4,11 +4,37 @@ title: Info
 description: General information about all routes that are offered by geniURL's REST service
 ---
 
-## General info
-All routes support gzip, deflate and brotli compression.  
-  
-Also all routes always return the properties `error` and `matches`.  
+## Base URL
+I host a public instance on this base URL:
+```
+https://api.sv443.net/geniurl/v2/
+```
+
+<br>
+
+## Rate Limiting
+The public instance is rate limited to 25 requests within a 30 second timeframe.  
+To know how many requests you have sent and are still able to send, refer to the following headers that are attached to each response:
+| Name                    | Description                                                                                                     |
+| :---------------------- | :-------------------------------------------------------------------------------------------------------------- |
+| `Retry-After`           | Number of seconds you need to wait until being able to send another request.                                    |
+| `X-RateLimit-Reset`     | An [ISO 8601 UTC timestamp](https://en.wikipedia.org/wiki/ISO_8601) indicating when you can send more requests. |
+| `X-RateLimit-Limit`     | The total number of requests you can send per timeframe.                                                        |
+| `X-RateLimit-Remaining` | The requests you are still able to send in the current timeframe.                                               |
+
+<br>
+
+## Error detection
+All routes always return the properties `error` and `matches`.  
 They can be used to determine whether a response has succeeded (error = false, matches > 0), is errored (error = true, matches = null) or just didn't yield any results (error = true, matches = 0).  
+  
+Additionally, you can use the [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) to find out whether a request has succeeded or not.
+
+<br>
+
+## Compression
+All routes support gzip, deflate and brotli compression.  
+If no compression support is provided via the `Accept-Encoding` header, the content will be transmitted uncompressed.
 
 <br>
 

+ 6 - 1
www/docs/routes/search.md

@@ -29,7 +29,12 @@ Make sure these parameters are [percent/URL-encoded.](https://en.wikipedia.org/w
 **Optional URL Parameters:**  
 `?format=json/xml`  
 Use this optional parameter to change the response format from the default (`json`) to `xml`  
-The structure of the XML data is similar to the shown JSON data.
+The structure of the XML data is similar to the shown JSON data.  
+  
+`?limit=n`  
+When provided, this parameter limits the amount of possible results.  
+It will default to 10 if not provided or set to a number above 10.  
+If set to a number below 1, it will default to 1.
 
 <br>
 

+ 1 - 1
www/docs/manual-search.md → www/docs/try-it.md

@@ -1,6 +1,6 @@
 ---
 lang: en-US
-title: Manual Search
+title: Try It
 description: Try out geniURL by manually searching for lyrics metadata
 ---