mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 13:37:01 +03:00
fix eslint errors
This commit is contained in:
@@ -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<Response> {
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user