From cef6d5f365c017450f620058f9562d29c9c41069 Mon Sep 17 00:00:00 2001 From: Michael C Date: Sun, 4 Jul 2021 23:36:47 -0400 Subject: [PATCH] fix eslint errors --- src/routes/getLockCategories.ts | 6 +++--- src/routes/getLockCategoriesByHash.ts | 4 ++-- test/cases/getLockCategories.ts | 10 +++++----- test/cases/getLockCategoriesByHash.ts | 18 +++++++++--------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/routes/getLockCategories.ts b/src/routes/getLockCategories.ts index f94b9ec..bbe922c 100644 --- a/src/routes/getLockCategories.ts +++ b/src/routes/getLockCategories.ts @@ -4,7 +4,7 @@ import {Request, Response} from 'express'; import { Category, VideoID } from "../types/segments.model"; import { UserID } from '../types/user.model'; -export async function getLockCategories(req: Request, res: Response) { +export async function getLockCategories(req: Request, res: Response): Promise { const videoID = req.query.videoID as VideoID; if (videoID == undefined) { @@ -14,11 +14,11 @@ export async function getLockCategories(req: Request, res: Response) { try { // Get existing lock categories markers - let lockCategoryList = await db.prepare('all', 'SELECT "category", "userID" from "lockCategories" where "videoID" = ?', [videoID]) as {category: Category, userID: UserID}[] + const lockCategoryList = await db.prepare('all', 'SELECT "category", "userID" from "lockCategories" where "videoID" = ?', [videoID]) as {category: Category, userID: UserID}[]; if (lockCategoryList.length === 0 || !lockCategoryList[0]) { return res.sendStatus(404); } else { - return res.send(lockCategoryList) + return res.send(lockCategoryList); } } catch (err) { Logger.error(err); diff --git a/src/routes/getLockCategoriesByHash.ts b/src/routes/getLockCategoriesByHash.ts index 34b3456..b236a16 100644 --- a/src/routes/getLockCategoriesByHash.ts +++ b/src/routes/getLockCategoriesByHash.ts @@ -14,11 +14,11 @@ export async function getLockCategoriesByHash(req: Request, res: Response): Prom try { // Get existing lock categories markers - let lockCategoryList = await db.prepare('all', 'SELECT * from "lockCategories" where "hashedVideoID" LIKE ? ORDER BY videoID', [hashPrefix + '%']) as {videoID: VideoID, userID: UserID,category: Category}[] + const lockCategoryList = await db.prepare('all', 'SELECT * from "lockCategories" where "hashedVideoID" LIKE ? ORDER BY videoID', [hashPrefix + '%']) as {videoID: VideoID, userID: UserID,category: Category}[]; if (lockCategoryList.length === 0 || !lockCategoryList[0]) { return res.sendStatus(404); } else { - return res.send(lockCategoryList) + return res.send(lockCategoryList); } } catch (err) { Logger.error(err); diff --git a/test/cases/getLockCategories.ts b/test/cases/getLockCategories.ts index 1f62642..23b9e8a 100644 --- a/test/cases/getLockCategories.ts +++ b/test/cases/getLockCategories.ts @@ -19,7 +19,7 @@ describe('getLockCategories', () => { }); it('Should update the database version when starting the application', async () => { - let version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value; + const version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value; if (version > 1) return; else return 'Version isn\'t greater than 1. Version is ' + version; }); @@ -42,7 +42,7 @@ describe('getLockCategories', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('Should be able to get single locks', (done: Done) => { @@ -61,7 +61,7 @@ describe('getLockCategories', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 404 if no lock exists', (done: Done) => { @@ -70,7 +70,7 @@ describe('getLockCategories', () => { if (res.status !== 404) done('non 404 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 400 if no videoID specified', (done: Done) => { @@ -79,6 +79,6 @@ describe('getLockCategories', () => { if (res.status !== 400) done('non 400 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); }); diff --git a/test/cases/getLockCategoriesByHash.ts b/test/cases/getLockCategoriesByHash.ts index 312f2ed..a101b0a 100644 --- a/test/cases/getLockCategoriesByHash.ts +++ b/test/cases/getLockCategoriesByHash.ts @@ -22,7 +22,7 @@ describe('getLockCategoriesByHash', () => { }); it('Database should be greater or equal to version 18', async () => { - let version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value; + const version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value; if (version >= 18) return; else return 'Version isn\'t greater than 18. Version is ' + version; }); @@ -45,7 +45,7 @@ describe('getLockCategoriesByHash', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('Should be able to get single locks', (done: Done) => { @@ -64,7 +64,7 @@ describe('getLockCategoriesByHash', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('Should be able to get by half full hash', (done: Done) => { @@ -83,7 +83,7 @@ describe('getLockCategoriesByHash', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('Should be able to get multiple by similar hash', (done: Done) => { @@ -104,7 +104,7 @@ describe('getLockCategoriesByHash', () => { } } }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 404 once hash prefix varies', (done: Done) => { @@ -113,7 +113,7 @@ describe('getLockCategoriesByHash', () => { if (res.status !== 404) done('non 404 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 404 if no lock exists', (done: Done) => { @@ -122,7 +122,7 @@ describe('getLockCategoriesByHash', () => { if (res.status !== 404) done('non 404 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 400 if no videoID specified', (done: Done) => { @@ -131,7 +131,7 @@ describe('getLockCategoriesByHash', () => { if (res.status !== 400) done('non 400 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); it('should return 400 if full hash sent', (done: Done) => { @@ -140,6 +140,6 @@ describe('getLockCategoriesByHash', () => { if (res.status !== 400) done('non 400 (' + res.status + ')'); else done(); // pass }) - .catch(err => ("couldn't call endpoint")); + .catch(() => ("couldn't call endpoint")); }); });