Forráskód Böngészése

Merge pull request #6 from Sv443/feat/ts_migration

Sven Fehler 2 éve
szülő
commit
91836229f6
5 módosított fájl, 9 hozzáadás és 5 törlés
  1. 2 0
      changelog.md
  2. 1 1
      src/error.ts
  3. 3 3
      src/server.ts
  4. 1 1
      src/songMeta.ts
  5. 2 0
      src/types.d.ts

+ 2 - 0
changelog.md

@@ -10,6 +10,8 @@
 - Migrated code to TypeScript
 - Added new metadata:
     - release date
+    - featured artists
+    - images of artists
 
 <br>
 

+ 1 - 1
src/error.ts

@@ -1,4 +1,4 @@
-const k = require("kleur");
+import k from "kleur";
 
 /**
  * Handles an error

+ 3 - 3
src/server.ts

@@ -1,5 +1,5 @@
 import compression from "compression";
-import express, { ErrorRequestHandler, NextFunction, Request, Response } from "express";
+import express, { NextFunction, Request, Response } from "express";
 import { check as portUsed } from "tcp-port-used";
 import helmet from "helmet";
 import { RateLimiterMemory, RateLimiterRes } from "rate-limiter-flexible";
@@ -10,8 +10,8 @@ import jsonToXml from "js2xmlparser";
 import packageJson from "../package.json";
 import { error } from "./error";
 import { getMeta } from "./songMeta";
-import { ResponseType } from "./types";
-import { Errors, Stringifiable } from "svcorelib";
+import type { ResponseType } from "./types";
+import type { Stringifiable } from "svcorelib";
 
 const app = express();
 

+ 1 - 1
src/songMeta.ts

@@ -96,7 +96,7 @@ export async function getMeta({ q, artist, song }: Partial<Record<"q" | "artist"
                 .sort(([, valA], [, valB]) => valA > valB ? 1 : -1)
                 .map(e => e[0]);
 
-            const oldHits = reserialize(hits as unknown as JSONCompatible) as unknown as MetaSearchHit[];
+            const oldHits = [...hits];
 
             hits = bestMatches
                 .map(uuid => oldHits.find(h => h.uuid === uuid))

+ 2 - 0
src/types.d.ts

@@ -7,6 +7,7 @@ interface Artist {
     headerImage: string | null;
 }
 
+/** geniURL song meta object */
 export interface SongMeta {
     url: string;
     path: string;
@@ -39,6 +40,7 @@ export type ResponseFormat = "json" | "xml";
 
 //#SECTION API
 
+/** The entire object returned by the search endpoint of the genius API */
 export type ApiSearchResult = {
     response: {
         hits: SearchHit[];