mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Update dependencies & eslint
- update API-Docs link - cast err as string to appease eslint - update package and bump minimum to fix security issue - removed unnecessary filters from gitignore
This commit is contained in:
parent
954ac1eb07
commit
1c2dd055c1
24 changed files with 1374 additions and 1107 deletions
68
.gitignore
vendored
68
.gitignore
vendored
|
@ -2,47 +2,9 @@
|
|||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
@ -53,40 +15,10 @@ typings/
|
|||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Databases
|
||||
databases/sponsorTimes.db
|
||||
databases/sponsorTimes.db-shm
|
||||
|
|
|
@ -34,4 +34,4 @@ If you want to make changes, run `npm run dev` to automatically reload the serve
|
|||
|
||||
# API Docs
|
||||
|
||||
Available [here](https://github.com/ajayyy/SponsorBlock/wiki/API-Docs)
|
||||
Available [here](https://wiki.sponsor.ajay.app/index.php/API_Docs)
|
||||
|
|
2317
package-lock.json
generated
2317
package-lock.json
generated
File diff suppressed because it is too large
Load diff
30
package.json
30
package.json
|
@ -17,35 +17,35 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ajayyy/lru-diskcache": "^1.1.9",
|
||||
"@types/request": "^2.48.6",
|
||||
"better-sqlite3": "^7.4.1",
|
||||
"@types/request": "^2.48.7",
|
||||
"better-sqlite3": "^7.4.3",
|
||||
"cron": "^1.8.2",
|
||||
"express": "^4.17.1",
|
||||
"express-promise-router": "^4.1.0",
|
||||
"express-rate-limit": "^5.3.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"pg": "^8.6.0",
|
||||
"pg": "^8.7.1",
|
||||
"redis": "^3.1.2",
|
||||
"sync-mysql": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^5.4.3",
|
||||
"@types/better-sqlite3": "^7.4.0",
|
||||
"@types/cron": "^1.7.3",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/express-rate-limit": "^5.1.3",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.3.0",
|
||||
"@types/node-fetch": "^2.5.11",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.7.4",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/pg": "^8.6.1",
|
||||
"@types/redis": "^2.8.31",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
||||
"@typescript-eslint/parser": "^4.28.2",
|
||||
"eslint": "^7.30.0",
|
||||
"mocha": "^9.0.2",
|
||||
"nodemon": "^2.0.2",
|
||||
"sinon": "^11.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
||||
"@typescript-eslint/parser": "^4.29.3",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.0",
|
||||
"nodemon": "^2.0.12",
|
||||
"sinon": "^11.1.2",
|
||||
"ts-mock-imports": "^1.3.7",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.3.5"
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ export const archiveDownvoteSegment = async (dayLimit: number, voteLimit: number
|
|||
|
||||
} catch (err) {
|
||||
Logger.error("Execption when insert segment in archivedSponsorTimes");
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ export const archiveDownvoteSegment = async (dayLimit: number, voteLimit: number
|
|||
|
||||
} catch (err) {
|
||||
Logger.error("Execption when deleting segment in sponsorTimes");
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ export class Postgres implements IDatabase {
|
|||
await this.applyIndexes(this.config.fileNamePrefix, this.config.dbSchemaFolder);
|
||||
} catch (e) {
|
||||
Logger.warn("Applying indexes failed. See https://github.com/ajayyy/SponsorBlockServer/wiki/Postgres-Extensions for more information.");
|
||||
Logger.warn(e);
|
||||
Logger.warn(e as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export function addUnlistedVideo(req: Request, res: Response): Response {
|
|||
const timeSubmitted = Date.now();
|
||||
db.prepare("run", `INSERT INTO "unlistedVideos" ("videoID", "year", "views", "channelID", "timeSubmitted") values (?, ?, ?, ?, ?)`, [videoID, year, views, channelID, timeSubmitted]);
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ async function queueDump(): Promise<void> {
|
|||
|
||||
lastUpdate = startTime;
|
||||
} catch(e) {
|
||||
Logger.error(e);
|
||||
Logger.error(e as string);
|
||||
} finally {
|
||||
updateQueued = false;
|
||||
updateRunning = false;
|
||||
|
|
|
@ -22,7 +22,7 @@ export async function getIsUserVIP(req: Request, res: Response): Promise<Respons
|
|||
vip: vipState,
|
||||
});
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export async function getLockCategories(req: Request, res: Response): Promise<Re
|
|||
categories
|
||||
});
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export async function getLockCategoriesByHash(req: Request, res: Response): Prom
|
|||
// merge all locks
|
||||
return res.send(mergeLocks(lockedRows));
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ async function getSegmentsByVideoID(req: Request, videoID: VideoID, categories:
|
|||
return segments;
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash,
|
|||
return segments;
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function getUsername(req: Request, res: Response): Promise<Response
|
|||
});
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export async function getViewsForUser(req: Request, res: Response): Promise<Resp
|
|||
return res.sendStatus(404);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export async function postLockCategories(req: Request, res: Response): Promise<s
|
|||
await db.prepare("run", `INSERT INTO "lockCategories" ("videoID", "userID", "category", "hashedVideoID", "reason") VALUES(?, ?, ?, ?, ?)`, [videoID, userID, category, hashedVideoID, reason]);
|
||||
} catch (err) {
|
||||
Logger.error(`Error submitting 'lockCategories' marker for category '${category}' for video '${videoID}'`);
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
res.status(500).json({
|
||||
message: "Internal Server Error: Could not write marker to the database.",
|
||||
});
|
||||
|
@ -89,7 +89,7 @@ export async function postLockCategories(req: Request, res: Response): Promise<s
|
|||
[reason, userID, videoID, category]);
|
||||
} catch (err) {
|
||||
Logger.error(`Error submitting 'lockCategories' marker for category '${category}' for video '${videoID}'`);
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
res.status(500).json({
|
||||
message: "Internal Server Error: Could not write marker to the database.",
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ export async function postPurgeAllSegments(req: Request, res: Response): Promise
|
|||
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1 WHERE "videoID" = ?`, [videoID]);
|
||||
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
return res.sendStatus(200);
|
||||
|
|
|
@ -92,7 +92,7 @@ export async function postSegmentShift(req: Request, res: Response): Promise<Res
|
|||
}
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ export async function postSkipSegments(req: Request, res: Response): Promise<Res
|
|||
});
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ export async function setUsername(req: Request, res: Response): Promise<Response
|
|||
}
|
||||
}
|
||||
catch (error) {
|
||||
Logger.error(error);
|
||||
Logger.error(error as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ export async function setUsername(req: Request, res: Response): Promise<Response
|
|||
|
||||
return res.sendStatus(200);
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ export async function voteOnSponsorTime(req: Request, res: Response): Promise<Re
|
|||
}
|
||||
return res.status(finalResponse.finalStatus).send(finalResponse.finalMessage ?? undefined);
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
Logger.error(err as string);
|
||||
return res.status(500).json({error: "Internal error creating segment vote"});
|
||||
}
|
||||
}
|
|
@ -106,6 +106,6 @@ export interface APIVideoData {
|
|||
}
|
||||
|
||||
export interface APIVideoInfo {
|
||||
err: string | boolean,
|
||||
err: boolean | string,
|
||||
data?: APIVideoData
|
||||
}
|
|
@ -8,13 +8,13 @@ export function getIP(req: Request): IPAddress {
|
|||
}
|
||||
|
||||
switch (config.behindProxy as string) {
|
||||
case "X-Forwarded-For":
|
||||
return req.headers["x-forwarded-for"] as IPAddress;
|
||||
case "Cloudflare":
|
||||
return req.headers["cf-connecting-ip"] as IPAddress;
|
||||
case "X-Real-IP":
|
||||
return req.headers["x-real-ip"] as IPAddress;
|
||||
default:
|
||||
return req.connection.remoteAddress as IPAddress;
|
||||
case "X-Forwarded-For":
|
||||
return req.headers["x-forwarded-for"] as IPAddress;
|
||||
case "Cloudflare":
|
||||
return req.headers["cf-connecting-ip"] as IPAddress;
|
||||
case "X-Real-IP":
|
||||
return req.headers["x-real-ip"] as IPAddress;
|
||||
default:
|
||||
return req.connection.remoteAddress as IPAddress;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ export class YouTubeAPI {
|
|||
return { err: null, data: JSON.parse(data) };
|
||||
}
|
||||
} catch (err) {
|
||||
return { err };
|
||||
return { err: err as string | boolean, data: null };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ export class YouTubeAPI {
|
|||
return { err: result.statusText, data: null };
|
||||
}
|
||||
} catch (err) {
|
||||
return {err, data: null};
|
||||
return {err: err as string | boolean, data: null};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import fetch from "node-fetch";
|
||||
import { Done, getbaseURL, partialDeepEquals } from "../utils";
|
||||
import { Done, getbaseURL } from "../utils";
|
||||
import { db, privateDB } from "../../src/databases/databases";
|
||||
import { getHash } from "../../src/utils/getHash";
|
||||
import assert from "assert";
|
||||
|
|
Loading…
Reference in a new issue