Sv443 4 месяцев назад
Родитель
Сommit
beca47ef83
2 измененных файлов с 5 добавлено и 12 удалено
  1. 4 6
      src/index.ts
  2. 1 6
      test/hooks.ts

+ 4 - 6
src/index.ts

@@ -6,21 +6,19 @@ import { error } from "@src/error.js";
 const { env } = process;
 
 async function init() {
-  try
-  {
+  try {
     const missingEnvVars = [
       "HTTP_PORT",
       "GENIUS_ACCESS_TOKEN",
     ].reduce<string[]>((a, v) => ((typeof env[v] !== "string" || env[v]!.length < 1) ? a.concat(v) : a), []);
 
     if(missingEnvVars.length > 0)
-      throw new TypeError(`Missing environment variable(s):\n- ${missingEnvVars.join("\n- ")}`);
+      throw new Error(`Missing environment variable${missingEnvVars.length > 1 ? "s" : ""}:\n- ${missingEnvVars.join("\n- ")}`);
 
     await server.init();
   }
-  catch(err)
-  {
-    error("Error while initializing", err instanceof Error ? err : undefined, true);
+  catch(err) {
+    error("Encountered fatal error while initializing:", err instanceof Error ? err : undefined, true);
   }
 }
 

+ 1 - 6
test/hooks.ts

@@ -58,12 +58,7 @@ export function checkTranslationProps(translationObj: unknown) {
 //#region send requests
 
 /** Sends a request to the specified URL with the given options. Authentication and method "GET" are set by default. */
-export async function sendReq<
-  TAsJson extends boolean,
->(
-  path: string,
-  opts?: RequestInit & { asJson?: TAsJson },
-): Promise<{
+export async function sendReq(path: string, opts?: RequestInit): Promise<{
   res: Response;
   status: number;
   headers: Headers;