ソースを参照

fix: readme & property order

Sv443 2 年 前
コミット
8bc63318a2
4 ファイル変更22 行追加18 行削除
  1. 14 10
      README.md
  2. 2 2
      src/routes/album.ts
  3. 3 3
      src/songData.ts
  4. 3 3
      src/types.d.ts

+ 14 - 10
README.md

@@ -363,15 +363,19 @@ All routes support gzip and deflate compression.
 > {
 >     "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
+>     "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/..."
 >         }
->     ],
+>     },
 >     "timestamp": 1234567890123
 > }
 > ```
@@ -395,9 +399,9 @@ All routes support gzip and deflate compression.
 >
 > ```json
 > {
->     "error": false,
+>     "error": true,
 >     "matches": 0,
->     "translations": [],
+>     "message": "Couldn't find any associated album for this song",
 >     "timestamp": 1234567890123
 > }
 > ```

+ 2 - 2
src/routes/album.ts

@@ -23,9 +23,9 @@ export function initAlbumRoutes(router: Router) {
             const album = await getAlbum(Number(songId));
 
             if(!album)
-                return respond(res, "clientError", "Couldn't find any associated album for this song", format);
+                return respond(res, "clientError", "Couldn't find any associated album for this song", format, 0);
 
-            return respond(res, "success", { album }, format);
+            return respond(res, "success", { album }, format, 1);
         }
         catch(err)
         {

+ 3 - 3
src/songData.ts

@@ -208,11 +208,11 @@ export async function getAlbum(songId: number): Promise<Album | null> {
             const { response: { song: { album } } } = data;
 
             return {
-                coverArt: album.cover_art_url ?? null,
-                fullTitle: album.full_title,
-                id: album.id,
                 name: album.name,
+                fullTitle: album.full_title,
                 url: album.url,
+                coverArt: album.cover_art_url ?? null,
+                id: album.id,
                 artist: {
                     name: album.artist.name ?? null,
                     url: album.artist.url ?? null,

+ 3 - 3
src/types.d.ts

@@ -149,11 +149,11 @@ type ArtistObj = {
 }
 
 export interface Album {
-    coverArt: string | null;
-    fullTitle: string;
-    id: number;
     name: string;
+    fullTitle: string;
     url: string;
+    coverArt: string | null;
+    id: number;
     artist: Artist;
 }