mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 13:07:02 +03:00
fix TS declarations
This commit is contained in:
@@ -2,7 +2,7 @@ import {db} from '../databases/databases';
|
|||||||
import {Request, Response} from 'express';
|
import {Request, Response} from 'express';
|
||||||
import {UserID} from '../types/user.model';
|
import {UserID} from '../types/user.model';
|
||||||
|
|
||||||
function getFuzzyUserID(userName: String): Promise<[{userName: String, userID: UserID }]> {
|
function getFuzzyUserID(userName: String): Promise<{userName: String, userID: UserID }[]> {
|
||||||
// escape [_ % \] to avoid ReDOS
|
// escape [_ % \] to avoid ReDOS
|
||||||
userName = userName.replace(/\\/g, '\\\\')
|
userName = userName.replace(/\\/g, '\\\\')
|
||||||
.replace(/_/g, '\\_')
|
.replace(/_/g, '\\_')
|
||||||
@@ -17,7 +17,7 @@ function getFuzzyUserID(userName: String): Promise<[{userName: String, userID: U
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExactUserID(userName: String): Promise<[{userName: String, userID: UserID }]> {
|
function getExactUserID(userName: String): Promise<{userName: String, userID: UserID }[]> {
|
||||||
try {
|
try {
|
||||||
return db.prepare('all', `SELECT "userName", "userID" from "userNames" WHERE "userName" = ? LIMIT 10`, [userName]);
|
return db.prepare('all', `SELECT "userName", "userID" from "userNames" WHERE "userName" = ? LIMIT 10`, [userName]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -45,7 +45,7 @@ export async function getUserID(req: Request, res: Response) {
|
|||||||
if (results === undefined || results === null) {
|
if (results === undefined || results === null) {
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
return false;
|
return false;
|
||||||
} else if (results.length as number === 0) {
|
} else if (results.length === 0) {
|
||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user