diff --git a/src/app.ts b/src/app.ts index e7ba2c1..caee4fa 100644 --- a/src/app.ts +++ b/src/app.ts @@ -200,7 +200,7 @@ function setupRoutes(router: Router) { router.get("/api/generateToken/:type", generateTokenRequest); router.get("/api/verifyToken", verifyTokenRequest); - /* instanbul ignore next */ + /* istanbul ignore next */ if (config.postgres?.enabled) { router.get("/database", (req, res) => dumpDatabase(req, res, true)); router.get("/database.json", (req, res) => dumpDatabase(req, res, false)); diff --git a/src/routes/getIsUserVIP.ts b/src/routes/getIsUserVIP.ts index c8d048d..a9a3f3e 100644 --- a/src/routes/getIsUserVIP.ts +++ b/src/routes/getIsUserVIP.ts @@ -21,7 +21,7 @@ export async function getIsUserVIP(req: Request, res: Response): Promise /^([a-f0-9]{64}|[a-f0-9]{8} async function getSegmentFromDBByUUID(UUID: SegmentUUID): Promise { try { return await db.prepare("get", `SELECT * FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]); - } catch (err) { + } catch (err) /* istanbul ignore next */ { return null; } } @@ -62,7 +62,7 @@ async function endpoint(req: Request, res: Response): Promise { //send result return res.send(DBSegments); } - } catch (err) { + } catch (err) /* istanbul ignore next */ { if (err instanceof SyntaxError) { // catch JSON.parse error return res.status(400).send("UUIDs parameter does not match format requirements."); } else return res.sendStatus(500); diff --git a/src/routes/getSkipSegments.ts b/src/routes/getSkipSegments.ts index 7da485e..6c93822 100644 --- a/src/routes/getSkipSegments.ts +++ b/src/routes/getSkipSegments.ts @@ -107,7 +107,7 @@ async function getSegmentsByVideoID(req: Request, videoID: VideoID, categories: } return processedSegments; - } catch (err) { + } catch (err) /* istanbul ignore next */ { if (err) { Logger.error(err as string); return null; @@ -169,7 +169,7 @@ async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash, })); return segments; - } catch (err) { + } catch (err) /* istanbul ignore next */ { Logger.error(err as string); return null; } @@ -465,7 +465,7 @@ async function endpoint(req: Request, res: Response): Promise { //send result return res.send(segments); } - } catch (err) { + } catch (err) /* istanbul ignore next */ { if (err instanceof SyntaxError) { return res.status(400).send("Categories parameter does not match format requirements."); } else return res.sendStatus(500); diff --git a/src/routes/getStatus.ts b/src/routes/getStatus.ts index 7f764f5..1c56cee 100644 --- a/src/routes/getStatus.ts +++ b/src/routes/getStatus.ts @@ -27,7 +27,7 @@ export async function getStatus(req: Request, res: Response): Promise hostname: os.hostname() }; return value ? res.send(JSON.stringify(statusValues[value])) : res.send(statusValues); - } catch (err) { + } catch (err) /* istanbul ignore next */ { Logger.error(err as string); return res.sendStatus(500); } diff --git a/src/routes/getUserID.ts b/src/routes/getUserID.ts index c93fa62..5acf659 100644 --- a/src/routes/getUserID.ts +++ b/src/routes/getUserID.ts @@ -12,7 +12,7 @@ function getFuzzyUserID(userName: string): Promise<{userName: string, userID: Us try { return db.prepare("all", `SELECT "userName", "userID" FROM "userNames" WHERE "userName" LIKE ? ESCAPE '\\' LIMIT 10`, [userName]); - } catch (err) { + } catch (err) /* istanbul ignore next */ { return null; } } @@ -20,7 +20,7 @@ function getFuzzyUserID(userName: string): Promise<{userName: string, userID: Us function getExactUserID(userName: string): Promise<{userName: string, userID: UserID }[]> { try { return db.prepare("all", `SELECT "userName", "userID" from "userNames" WHERE "userName" = ? LIMIT 10`, [userName]); - } catch (err) { + } catch (err) /* istanbul ignore next */{ return null; } } @@ -42,6 +42,7 @@ export async function getUserID(req: Request, res: Response): Promise : await getFuzzyUserID(userName); if (results === undefined || results === null) { + /* istanbul ignore next */ return res.sendStatus(500); } else if (results.length === 0) { return res.sendStatus(404); diff --git a/src/routes/getUserInfo.ts b/src/routes/getUserInfo.ts index c0b1955..6492fdd 100644 --- a/src/routes/getUserInfo.ts +++ b/src/routes/getUserInfo.ts @@ -28,7 +28,7 @@ async function dbGetSubmittedSegmentSummary(userID: HashedUserID): Promise<{ min segmentCount: 0, }; } - } catch (err) { + } catch (err) /* istanbul ignore next */ { return null; } } @@ -37,7 +37,7 @@ async function dbGetIgnoredSegmentCount(userID: HashedUserID): Promise { try { const row = await db.prepare("get", `SELECT COUNT(*) as "ignoredSegmentCount" FROM "sponsorTimes" WHERE "userID" = ? AND ( "votes" <= -2 OR "shadowHidden" = 1 )`, [userID], { useReplica: true }); return row?.ignoredSegmentCount ?? 0; - } catch (err) { + } catch (err) /* istanbul ignore next */ { return null; } } @@ -46,7 +46,7 @@ async function dbGetUsername(userID: HashedUserID) { try { const row = await db.prepare("get", `SELECT "userName" FROM "userNames" WHERE "userID" = ?`, [userID]); return row?.userName ?? userID; - } catch (err) { + } catch (err) /* istanbul ignore next */ { return false; } } @@ -55,7 +55,7 @@ async function dbGetViewsForUser(userID: HashedUserID) { try { const row = await db.prepare("get", `SELECT SUM("views") as "viewCount" FROM "sponsorTimes" WHERE "userID" = ? AND "votes" > -2 AND "shadowHidden" != 1`, [userID], { useReplica: true }); return row?.viewCount ?? 0; - } catch (err) { + } catch (err) /* istanbul ignore next */ { return false; } } @@ -64,7 +64,7 @@ async function dbGetIgnoredViewsForUser(userID: HashedUserID) { try { const row = await db.prepare("get", `SELECT SUM("views") as "ignoredViewCount" FROM "sponsorTimes" WHERE "userID" = ? AND ( "votes" <= -2 OR "shadowHidden" = 1 )`, [userID], { useReplica: true }); return row?.ignoredViewCount ?? 0; - } catch (err) { + } catch (err) /* istanbul ignore next */ { return false; } } @@ -73,7 +73,7 @@ async function dbGetWarningsForUser(userID: HashedUserID): Promise { try { const row = await db.prepare("get", `SELECT COUNT(*) as total FROM "warnings" WHERE "userID" = ? AND "enabled" = 1`, [userID], { useReplica: true }); return row?.total ?? 0; - } catch (err) { + } catch (err) /* istanbul ignore next */ { Logger.error(`Couldn't get warnings for user ${userID}. returning 0`); return 0; } @@ -83,7 +83,7 @@ async function dbGetLastSegmentForUser(userID: HashedUserID): Promise { try { const row = await db.prepare("get", `SELECT count(*) as "userCount" FROM "shadowBannedUsers" WHERE "userID" = ? LIMIT 1`, [userID], { useReplica: true }); return row?.userCount > 0 ?? false; - } catch (err) { + } catch (err) /* istanbul ignore next */ { return false; } } @@ -195,7 +195,7 @@ async function getUserInfo(req: Request, res: Response): Promise { export async function endpoint(req: Request, res: Response): Promise { try { return await getUserInfo(req, res); - } catch (err) { + } catch (err) /* istanbul ignore next */ { if (err instanceof SyntaxError) { // catch JSON.parse error return res.status(400).send("Invalid values JSON"); } else return res.sendStatus(500); diff --git a/src/routes/getUserStats.ts b/src/routes/getUserStats.ts index 63185f4..ea239d1 100644 --- a/src/routes/getUserStats.ts +++ b/src/routes/getUserStats.ts @@ -71,7 +71,7 @@ async function dbGetUserSummary(userID: HashedUserID, fetchCategoryStats: boolea }; } return result; - } catch (err) /* instanbul ignore next */ { + } catch (err) /* istanbul ignore next */ { Logger.error(err as string); return null; } @@ -81,7 +81,7 @@ async function dbGetUsername(userID: HashedUserID) { try { const row = await db.prepare("get", `SELECT "userName" FROM "userNames" WHERE "userID" = ?`, [userID]); return row?.userName ?? userID; - } catch (err) /* instanbul ignore next */ { + } catch (err) /* istanbul ignore next */ { return false; } } diff --git a/src/routes/getUsername.ts b/src/routes/getUsername.ts index 28098fe..b3a2a7b 100644 --- a/src/routes/getUsername.ts +++ b/src/routes/getUsername.ts @@ -27,7 +27,7 @@ export async function getUsername(req: Request, res: Response): Promise