Explorar o código

feat: begin working on site

Sv443 hai 4 meses
pai
achega
321fa80597
Modificáronse 6 ficheiros con 1025 adicións e 32 borrados
  1. 4 2
      package.json
  2. 635 0
      pnpm-lock.yaml
  3. 19 9
      www/docs/.vuepress/config.mjs
  4. 11 21
      www/docs/README.md
  5. 6 0
      www/docs/docs/README.md
  6. 350 0
      www/docs/docs/routes.md

+ 4 - 2
package.json

@@ -6,8 +6,8 @@
   "scripts": {
     "start": "tsc && node --enable-source-maps out/src/index.js",
     "dev": "nodemon -e \"ts,d.ts\" -x \"pnpm start\"",
-    "dev-docs": "cd www && pnpm run dev",
-    "build-docs": "cd www && pnpm run build"
+    "www-dev": "cd www && pnpm run dev",
+    "www-build": "cd www && pnpm run build"
   },
   "repository": {
     "type": "git",
@@ -56,6 +56,8 @@
     "@types/tcp-port-used": "^1.0.4",
     "@typescript-eslint/eslint-plugin": "^6.21.0",
     "@typescript-eslint/parser": "^6.21.0",
+    "@vuepress/plugin-seo": "2.0.0-rc.3",
+    "@vuepress/plugin-sitemap": "2.0.0-rc.3",
     "dotenv": "^16.4.5",
     "eslint": "^8.57.1",
     "jest": "^29.7.0",

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 635 - 0
pnpm-lock.yaml


+ 19 - 9
www/docs/.vuepress/config.mjs

@@ -1,18 +1,28 @@
-import { defaultTheme } from "@vuepress/theme-default"
-import { defineUserConfig } from "vuepress/cli"
-import { viteBundler } from "@vuepress/bundler-vite"
+import { defineUserConfig } from "vuepress/cli";
+import { defaultTheme } from "@vuepress/theme-default";
+import { viteBundler } from "@vuepress/bundler-vite";
+import { seoPlugin } from "@vuepress/plugin-seo";
+import { sitemapPlugin } from "@vuepress/plugin-sitemap";
+import rootPkgJson from "../../../package.json";
 
 export default defineUserConfig({
   lang: "en-US",
-
-  title: "geniURL Homepage and Docs",
-  description: "geniURL is a simple JSON and XML REST API to search for song metadata, the lyrics URL and lyrics translations on genius.com",
-
+  base: "/docs/v2/",
+  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",
 
     navbar: ["/", "/get-started"],
   }),
-
   bundler: viteBundler(),
-})
+  plugins: [
+    seoPlugin({
+      hostname: "https://api.sv443.net",
+      author: rootPkgJson.author,
+    }),
+    sitemapPlugin({
+      hostname: "https://api.sv443.net",
+    }),
+  ]
+});

+ 11 - 21
www/docs/README.md

@@ -3,31 +3,21 @@ home: true
 title: Home
 heroImage: https://vuejs.press/images/hero.png
 actions:
-  - text: Get Started
-    link: /getting-started.html
+  - text: Documentation
+    link: /docs/
     type: primary
 
-  - text: Introduction
-    link: https://vuejs.press/guide/introduction.html
+  - text: Manual search
+    link: /manual-search.html
     type: secondary
 
 features:
-  - title: Simplicity First
-    details: Minimal setup with markdown-centered project structure helps you focus on writing.
-  - title: Vue-Powered
-    details: Enjoy the dev experience of Vue, use Vue components in markdown, and develop custom themes with Vue.
-  - title: Performant
-    details: VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
-  - title: Themes
-    details: Providing a default theme out of the box. You can also choose a community theme or create your own one.
-  - title: Plugins
-    details: Flexible plugin API, allowing plugins to provide lots of plug-and-play features for your site.
-  - title: Bundlers
-    details: Default bundler is Vite, while Webpack is also supported. Choose the one you like!
+  - title: Format conversion
+    details: geniURL can convert the JSON data to XML if that is easier to use in your environment.
+  - title: Free and easy to use
+    details: The API is free to use and doesn't require authentication. You can use it for any purpose, even commercially. Note that rate limits apply.
+  - title: Open source
+    details: The source code for geniURL is available on GitHub. You can use it as a reference or contribute to the project.
 
-footer: MIT Licensed | Copyright © 2018-present VuePress Community
+footer: "MIT License | Copyright © 2024 Sv443"
 ---
-
-This is the content of home page. Check [Home Page Docs][default-theme-home] for more details.
-
-[default-theme-home]: https://vuejs.press/reference/default-theme/frontmatter.html#home-page

+ 6 - 0
www/docs/docs/README.md

@@ -0,0 +1,6 @@
+# geniURL Documentation
+
+<h3>
+
+- [Routes](./routes)
+</h3>

+ 350 - 0
www/docs/docs/routes.md

@@ -0,0 +1,350 @@
+## Routes:
+All routes support gzip, deflate and brotli compression.  
+  
+Also 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).  
+  
+These are the available routes:
+- [Search](#get-search)
+    - [Search (only top result)](#get-searchtop)
+- [Translations](#get-translationssongid)
+- [Associated Album](#get-albumsongid)
+
+<br><br>
+
+### GET `/search`
+
+This route gives you up to 10 results for a provided search query.  
+The returned payload contains various data like the lyrics website URL, song and thumbnail metadata and more (see below).
+
+<br>
+
+**URL Parameters:**  
+`?q=search%20query`  
+This parameter should contain both the song and artist name. For best result artist name should come first, separate with a whitespace or hyphen.  
+Sometimes the song name alone might be enough but the results vary greatly.  
+If you want to search for a remix (like `?q=Artist - Song (Artist2 Remix)`), this parameter will yield better results.  
+Make sure the search query is [percent/URL-encoded.](https://en.wikipedia.org/wiki/Percent-encoding)  
+
+**OR**
+
+`?artist=name` and `?song=name`  
+Instead of `?q`, you can also use `?artist` and `?song`.  
+Make sure these parameters are [percent/URL-encoded.](https://en.wikipedia.org/wiki/Percent-encoding)
+
+<br>
+
+**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.
+
+<br>
+
+**Response:**  
+
+<details><summary><b>Successful response (click to view)</b></summary>
+
+```jsonc
+{
+    "error": false,
+    "matches": 10,
+    "top": {
+        "url": "https://genius.com/Artist-Foo-song-name-lyrics",
+        "path": "/Artist-Foo-song-name-lyrics",
+        "language": "en",
+        "meta": {
+            "title": "Song Name",
+            "fullTitle": "Song Name by Artist Foo (ft. Artist Bar)",
+            "artists": "Artist Foo (ft. Artist Bar)",
+            "primaryArtist": {
+                "name": "Artist Foo",
+                "url": "https://genius.com/artists/Artist-Foo",
+                "headerImage": "https://images.genius.com/...",
+                "image": "https://images.genius.com/..."
+            },
+            "featuredArtists": [
+                {
+                    "name": "Artist Bar",
+                    "url": "https://genius.com/artists/Artist-Bar",
+                    "headerImage": "https://images.genius.com/...",
+                    "image": "https://images.genius.com/..."
+                }
+            ],
+            "releaseDate": {
+                "year": 2018,
+                "month": 9,
+                "day": 12
+            }
+        },
+        "resources": {
+            "thumbnail": "https://images.genius.com/...",
+            "image": "https://images.genius.com/..."
+        },
+        "lyricsState": "complete",
+        "id": 42069
+    },
+    "all": [
+        // This array contains up to 10 objects with the same structure as 'top', sorted best match first
+        // The amount of objects in here is the same as the 'matches' property
+        // The first object of this array is exactly the same as 'top'
+    ]
+}
+```
+
+</details>
+<br>
+<details><summary>Errored response (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": null,
+    "message": "Something went wrong"
+}
+```
+
+</details>
+<br>
+<details><summary>Response when no results found (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": 0,
+    "message": "Found no results matching your search query"
+}
+```
+
+</details><br>
+
+<br><br><br>
+
+### GET `/search/top`
+
+This route is similar to `/search`, but it only gives the top result.  
+Use this if you are only interested in the top result and want to reduce traffic.
+
+<br>
+
+**URL Parameters:**  
+`?q=search%20query`  
+This parameter should contain both the song and artist name. For best result artist name should come first, separate with a whitespace or hyphen.  
+Sometimes the song name alone might be enough but the results vary greatly.  
+If you want to search for a remix (like `?q=Artist - Song (Artist2 Remix)`), this parameter will yield better results.  
+Make sure the search query is [percent/URL-encoded.](https://en.wikipedia.org/wiki/Percent-encoding)  
+
+**OR**
+
+`?artist=name` and `?song=name`  
+Instead of `?q`, you can also use `?artist` and `?song`.  
+Make sure these parameters are [percent/URL-encoded.](https://en.wikipedia.org/wiki/Percent-encoding)
+
+<br><br>
+
+**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.
+
+<br>
+
+**Response:**  
+
+<details><summary><b>Successful response (click to view)</b></summary>
+
+```jsonc
+{
+    "error": false,
+    "matches": 1,
+    "url": "https://genius.com/Artist-Foo-song-name-lyrics",
+    "path": "/Artist-Foo-song-name-lyrics",
+    "language": "en",
+    "meta": {
+        "title": "Song Name",
+        "fullTitle": "Song Name by Artist Foo (ft. Artist Bar)",
+        "artists": "Artist Foo (ft. Artist Bar)",
+        "primaryArtist": {
+            "name": "Artist Foo",
+            "url": "https://genius.com/artists/Artist-Foo",
+            "headerImage": "https://images.genius.com/...",
+            "image": "https://images.genius.com/..."
+        },
+        "featuredArtists": [
+            {
+                "name": "Artist Bar",
+                "url": "https://genius.com/artists/Artist-Bar",
+                "headerImage": "https://images.genius.com/...",
+                "image": "https://images.genius.com/..."
+            }
+        ],
+        "releaseDate": {
+            "year": 2018,
+            "month": 9,
+            "day": 12
+        }
+    },
+    "resources": {
+        "thumbnail": "https://images.genius.com/...",
+        "image": "https://images.genius.com/..."
+    },
+    "lyricsState": "complete",
+    "id": 42069
+}
+```
+
+</details>
+<br>
+<details><summary>Errored response (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": null,
+    "message": "Something went wrong"
+}
+```
+
+</details>
+<br>
+<details><summary>Response when no result found (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": 0,
+    "message": "Found no results matching your search query"
+}
+```
+
+</details><br>
+
+<br><br><br>
+
+### GET `/translations/:songId`
+
+This route returns all translations of a certain song.  
+Get the song ID from one of the [search routes.](#routes)  
+Example: `/translations/1644`
+
+<br>
+
+**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.
+
+<br>
+
+**Response:**  
+
+<details><summary><b>Successful response (click to view)</b></summary>
+
+```jsonc
+{
+    "error": false,
+    "matches": 1,
+    "translations": [
+        {
+            "language": "es",
+            "title": "Artist - Song (Traducción al Español)",
+            "url": "https://genius.com/Genius-traducciones-al-espanol-artist-song-al-espanol-lyrics",
+            "path": "/Genius-traducciones-al-espanol-artist-song-al-espanol-lyrics",
+            "id": 6942
+        }
+    ]
+}
+```
+
+</details>
+<br>
+<details><summary>Errored response (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": null,
+    "message": "Something went wrong"
+}
+```
+
+</details>
+<br>
+<details><summary>Response when no result found (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": 0,
+    "translations": []
+}
+```
+
+</details><br>
+
+<br><br><br>
+
+### GET `/album/:songId`
+
+This route returns any associated album for a specified song.  
+Get the song ID from one of the [search routes.](#routes)  
+Example: `/album/1644`
+
+<br>
+
+**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.
+
+<br>
+
+**Response:**  
+
+<details><summary><b>Successful response (click to view)</b></summary>
+
+```jsonc
+{
+    "error": false,
+    "matches": 1,
+    "album": {
+        "name": "Album",
+        "fullTitle": "Song by Artist",
+        "url": "https://genius.com/albums/Artist/Album",
+        "coverArt": "https://images.genius.com/...",
+        "id": 12345,
+        "artist": {
+            "name": "Artist",
+            "url": "https://genius.com/artists/Artist",
+            "image": "https://images.genius.com/...",
+            "headerImage": "https://images.genius.com/..."
+        }
+    }
+}
+```
+
+</details>
+<br>
+<details><summary>Errored response (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": null,
+    "message": "Something went wrong"
+}
+```
+
+</details>
+<br>
+<details><summary>Response when no result found (click to view)</summary>
+
+```json
+{
+    "error": true,
+    "matches": 0,
+    "message": "Couldn't find any associated album for this song"
+}
+```
+
+</details><br>

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio