Fix all 93 ESLint issues (3 errors, 90 warnings) (#666)

This commit is contained in:
Thomas Durieux
2026-04-15 09:04:22 +02:00
committed by GitHub
parent 1d97c76e7e
commit f4209110c7
28 changed files with 77 additions and 69 deletions
+2 -2
View File
@@ -80,8 +80,8 @@ const config: Config = {
}; };
for (const conf in process.env) { for (const conf in process.env) {
if ((config as any)[conf] !== undefined) { if ((config as unknown as Record<string, unknown>)[conf] !== undefined) {
(config as any)[conf] = process.env[conf]; (config as unknown as Record<string, string | undefined>)[conf] = process.env[conf];
} }
} }
+1 -1
View File
@@ -246,7 +246,7 @@ export default class AnonymizedFile {
anonymizerOptions: anonymizer.opt, anonymizerOptions: anonymizer.opt,
}, },
}) })
.on("error", (err) => { .on("error", (_err) => {
handleError( handleError(
new AnonymousError("file_not_found", { new AnonymousError("file_not_found", {
object: this, object: this,
+2 -2
View File
@@ -9,7 +9,7 @@ import User from "./User";
* Custom error message * Custom error message
*/ */
export default class AnonymousError extends CustomError { export default class AnonymousError extends CustomError {
value?: any; value?: unknown;
httpStatus?: number; httpStatus?: number;
cause?: Error; cause?: Error;
@@ -18,7 +18,7 @@ export default class AnonymousError extends CustomError {
opt?: { opt?: {
httpStatus?: number; httpStatus?: number;
cause?: Error; cause?: Error;
object?: any; object?: unknown;
} }
) { ) {
super(message); super(message);
+2 -2
View File
@@ -16,7 +16,7 @@ export default class Conference {
* @param status the new status * @param status the new status
* @param errorMessage a potential error message to display * @param errorMessage a potential error message to display
*/ */
async updateStatus(status: ConferenceStatus, errorMessage?: string) { async updateStatus(status: ConferenceStatus, _errorMessage?: string) {
this._data.status = status; this._data.status = status;
await this._data.save(); await this._data.save();
return; return;
@@ -104,7 +104,7 @@ export default class Conference {
return this._data.options; return this._data.options;
} }
toJSON(opt?: { billing: boolean }): any { toJSON(_opt?: { billing: boolean }): Record<string, unknown> {
const pricePerHourPerRepo = this._data.plan.pricePerRepository / 30; const pricePerHourPerRepo = this._data.plan.pricePerRepository / 30;
let price = 0; let price = 0;
const today = const today =
+1 -2
View File
@@ -3,7 +3,6 @@ import { Octokit } from "@octokit/rest";
import Repository from "./Repository"; import Repository from "./Repository";
import UserModel from "./model/users/users.model"; import UserModel from "./model/users/users.model";
import config from "../config"; import config from "../config";
import { RepositoryStatus } from "./types";
export function octokit(token: string) { export function octokit(token: string) {
return new Octokit({ return new Octokit({
@@ -19,7 +18,7 @@ export async function checkToken(token: string) {
try { try {
await oct.users.getAuthenticated(); await oct.users.getAuthenticated();
return true; return true;
} catch (error) { } catch {
return false; return false;
} }
} }
+3 -3
View File
@@ -37,7 +37,7 @@ export default class PullRequest {
if (this._model.source.accessToken) { if (this._model.source.accessToken) {
try { try {
return this._model.source.accessToken; return this._model.source.accessToken;
} catch (error) { } catch {
console.debug( console.debug(
"[ERROR] Token is invalid", "[ERROR] Token is invalid",
this._model.source.pullRequestId this._model.source.pullRequestId
@@ -240,7 +240,7 @@ export default class PullRequest {
} }
content() { content() {
const output: any = { const output: Record<string, unknown> = {
anonymizeDate: this._model.anonymizeDate, anonymizeDate: this._model.anonymizeDate,
merged: this._model.pullRequest.merged, merged: this._model.pullRequest.merged,
mergedDate: this._model.pullRequest.mergedDate, mergedDate: this._model.pullRequest.mergedDate,
@@ -259,7 +259,7 @@ export default class PullRequest {
} }
if (this.options.comments) { if (this.options.comments) {
output.comments = this._model.pullRequest.comments?.map((comment) => { output.comments = this._model.pullRequest.comments?.map((comment) => {
const o: any = {}; const o: Record<string, unknown> = {};
if (this.options.body) o.body = anonymizer.anonymize(comment.body); if (this.options.body) o.body = anonymizer.anonymize(comment.body);
if (this.options.username) if (this.options.username)
o.author = anonymizer.anonymize(comment.author); o.author = anonymizer.anonymize(comment.author);
-1
View File
@@ -1,5 +1,4 @@
import { model } from "mongoose"; import { model } from "mongoose";
import { join } from "path";
import { IFileDocument, IFileModel } from "./files.types"; import { IFileDocument, IFileModel } from "./files.types";
import FileSchema from "./files.schema"; import FileSchema from "./files.schema";
+1 -1
View File
@@ -31,7 +31,7 @@ export default class GitHubDownload extends GitHubBase {
response = await this.getZipUrl(); response = await this.getZipUrl();
} catch (error) { } catch (error) {
throw new AnonymousError("repo_not_found", { throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status || 404, httpStatus: (error as { status?: number }).status || 404,
object: this.data, object: this.data,
cause: error as Error, cause: error as Error,
}); });
+3 -3
View File
@@ -99,7 +99,7 @@ export class GitHubRepository {
} }
} catch (error) { } catch (error) {
throw new AnonymousError("repo_not_found", { throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status, httpStatus: (error as { status?: number }).status,
cause: error as Error, cause: error as Error,
object: this, object: this,
}); });
@@ -212,7 +212,7 @@ export async function getRepositoryFromGitHub(opt: {
if (opt.repo.indexOf(".git") > -1) { if (opt.repo.indexOf(".git") > -1) {
opt.repo = opt.repo.replace(".git", ""); opt.repo = opt.repo.replace(".git", "");
} }
let dbModel = null; let dbModel;
if (opt.repositoryID) { if (opt.repositoryID) {
dbModel = isConnected dbModel = isConnected
? await RepositoryModel.findById(opt.repositoryID) ? await RepositoryModel.findById(opt.repositoryID)
@@ -255,7 +255,7 @@ export async function getRepositoryFromGitHub(opt: {
}); });
} }
throw new AnonymousError("repo_not_found", { throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status, httpStatus: (error as { status?: number }).status,
object: { object: {
owner: opt.owner, owner: opt.owner,
repo: opt.repo, repo: opt.repo,
+5 -5
View File
@@ -70,7 +70,7 @@ export default class GitHubStream extends GitHubBase {
content.on("error", (error) => { content.on("error", (error) => {
error = new AnonymousError("file_not_found", { error = new AnonymousError("file_not_found", {
httpStatus: (error as any).status || (error as any).httpStatus, httpStatus: (error as { status?: number; httpStatus?: number }).status || (error as { httpStatus?: number }).httpStatus,
cause: error as Error, cause: error as Error,
object: filePath, object: filePath,
}); });
@@ -85,7 +85,7 @@ export default class GitHubStream extends GitHubBase {
async getFileContent(file: AnonymizedFile): Promise<stream.Readable> { async getFileContent(file: AnonymizedFile): Promise<stream.Readable> {
try { try {
void file.filePath; void file.filePath;
} catch (_) { } catch {
// compute the original path if ambiguous // compute the original path if ambiguous
await file.originalPath(); await file.originalPath();
} }
@@ -139,7 +139,7 @@ export default class GitHubStream extends GitHubBase {
file: 0, file: 0,
}; };
const output: IFile[] = []; const output: IFile[] = [];
let data = null; let data;
try { try {
data = await this.getGHTree(sha, count, { data = await this.getGHTree(sha, count, {
recursive: false, recursive: false,
@@ -152,12 +152,12 @@ export default class GitHubStream extends GitHubBase {
output.push(...this.tree2Tree(data.tree, parentPath)); output.push(...this.tree2Tree(data.tree, parentPath));
} catch (error) { } catch (error) {
console.log(error); console.log(error);
if ((error as any).status == 409 || (error as any).status == 404) { if ((error as { status?: number }).status == 409 || (error as { status?: number }).status == 404) {
// empty repo // empty repo
data = { tree: [] }; data = { tree: [] };
} else { } else {
throw new AnonymousError("repo_not_found", { throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status || 404, httpStatus: (error as { status?: number }).status || 404,
object: this.data, object: this.data,
cause: error as Error, cause: error as Error,
}); });
+2 -1
View File
@@ -8,6 +8,7 @@ export default class Zip implements SourceBase {
type = "Zip"; type = "Zip";
url?: string; url?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(data: any, readonly repoId: string) { constructor(data: any, readonly repoId: string) {
this.url = data.url; this.url = data.url;
} }
@@ -28,7 +29,7 @@ export default class Zip implements SourceBase {
return storage.read(file.repository.repoId, file.filePath); return storage.read(file.repository.repoId, file.filePath);
} }
toJSON(): any { toJSON(): { type: string } {
return { return {
type: this.type, type: this.type,
}; };
+7 -7
View File
@@ -25,7 +25,7 @@ export default class FileSystem extends StorageBase {
const stat = await fs.promises.stat(fullPath); const stat = await fs.promises.stat(fullPath);
if (stat.isDirectory()) return FILE_TYPE.FOLDER; if (stat.isDirectory()) return FILE_TYPE.FOLDER;
if (stat.isFile()) return FILE_TYPE.FILE; if (stat.isFile()) return FILE_TYPE.FILE;
} catch (_) { } catch {
// ignore file not found or not downloaded // ignore file not found or not downloaded
} }
return FILE_TYPE.NOT_FOUND; return FILE_TYPE.NOT_FOUND;
@@ -65,13 +65,13 @@ export default class FileSystem extends StorageBase {
try { try {
await this.mk(repoId, dirname(p)); await this.mk(repoId, dirname(p));
if (data instanceof Readable) { if (data instanceof Readable) {
data.on("error", (err) => { data.on("error", (_err) => {
this.rm(repoId, p); this.rm(repoId, p);
}); });
} }
return await fs.promises.writeFile(fullPath, data, "utf-8"); return await fs.promises.writeFile(fullPath, data, "utf-8");
} catch (err: any) { } catch {
// throw err; // write error ignored
} }
} }
@@ -91,8 +91,8 @@ export default class FileSystem extends StorageBase {
await fs.promises.mkdir(fullPath, { await fs.promises.mkdir(fullPath, {
recursive: true, recursive: true,
}); });
} catch (err: any) { } catch (err: unknown) {
if (err.code !== "EEXIST") { if (err instanceof Error && (err as NodeJS.ErrnoException).code !== "EEXIST") {
throw err; throw err;
} }
} }
@@ -135,7 +135,7 @@ export default class FileSystem extends StorageBase {
}) })
); );
} }
} catch (error) { } catch {
// ignore stat errors for individual files // ignore stat errors for individual files
} }
} }
+3 -3
View File
@@ -55,7 +55,7 @@ export default class S3Storage extends StorageBase {
// if we can get the file info, it is a file // if we can get the file info, it is a file
await this.fileInfo(repoId, path); await this.fileInfo(repoId, path);
return FILE_TYPE.FILE; return FILE_TYPE.FILE;
} catch (err) { } catch {
// check if it is a directory // check if it is a directory
const data = await this.client().listObjectsV2({ const data = await this.client().listObjectsV2({
Bucket: config.S3_BUCKET, Bucket: config.S3_BUCKET,
@@ -69,7 +69,7 @@ export default class S3Storage extends StorageBase {
} }
/** @override */ /** @override */
async mk(repoId: string, dir: string = ""): Promise<void> { async mk(repoId: string, _dir: string = ""): Promise<void> {
// no need to create folder on S3 // no need to create folder on S3
} }
@@ -125,7 +125,7 @@ export default class S3Storage extends StorageBase {
} else { } else {
res.end(); res.end();
} }
} catch (error) { } catch {
try { try {
res.status(500); res.status(500);
} catch (err) { } catch (err) {
+6 -5
View File
@@ -14,11 +14,12 @@ export default async function (job: SandboxedJob<Repository, void>) {
getRepository: typeof getRepositoryImport; getRepository: typeof getRepositoryImport;
} = require("../../server/database"); } = require("../../server/database");
console.log(`[QUEUE] ${job.data.repoId} is going to be downloaded`); console.log(`[QUEUE] ${job.data.repoId} is going to be downloaded`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let statusInterval: any = null; let statusInterval: any = null;
await connect(); await connect();
const repo = await getRepository(job.data.repoId); const repo = await getRepository(job.data.repoId);
try { try {
let progress: any = null; let progress: { status: string } | null = null;
statusInterval = setInterval(async () => { statusInterval = setInterval(async () => {
try { try {
if ( if (
@@ -37,7 +38,7 @@ export default async function (job: SandboxedJob<Repository, void>) {
); );
await repo.updateStatus(repo.status, progress?.status || ""); await repo.updateStatus(repo.status, progress?.status || "");
} }
} catch (_) { } catch {
// ignore error // ignore error
} }
}, 1000); }, 1000);
@@ -61,14 +62,14 @@ export default async function (job: SandboxedJob<Repository, void>) {
} }
throw error; throw error;
} }
} catch (error: any) { } catch (error: unknown) {
clearInterval(statusInterval); clearInterval(statusInterval);
console.log(`[QUEUE] ${job.data.repoId} is finished with an error`, error); console.log(`[QUEUE] ${job.data.repoId} is finished with an error`, error);
setTimeout(async () => { setTimeout(async () => {
// delay to avoid double saving // delay to avoid double saving
try { try {
await repo.updateStatus(RepositoryStatus.ERROR, error.message); await repo.updateStatus(RepositoryStatus.ERROR, (error as Error).message);
} catch (ignore) {} } catch { /* ignored */ }
}, 400); }, 400);
} finally { } finally {
clearInterval(statusInterval); clearInterval(statusInterval);
+1 -1
View File
@@ -17,7 +17,7 @@ export default async function (job: SandboxedJob<Repository, void>) {
); );
const repo = await getRepository(job.data.repoId); const repo = await getRepository(job.data.repoId);
await repo.removeCache(); await repo.removeCache();
} catch (error) { } catch {
// error already handled // error already handled
} finally { } finally {
console.log(`[QUEUE] Cache of ${job.data.repoId} is removed.`); console.log(`[QUEUE] Cache of ${job.data.repoId} is removed.`);
+1 -1
View File
@@ -26,7 +26,7 @@ export default async function (job: SandboxedJob<Repository, void>) {
} }
throw error; throw error;
} }
} catch (error) { } catch {
// error already handled // error already handled
} finally { } finally {
console.log(`[QUEUE] ${job.data.repoId} is removed`); console.log(`[QUEUE] ${job.data.repoId} is removed`);
+1 -1
View File
@@ -24,7 +24,7 @@ export async function connect() {
return database; return database;
} }
export async function getRepository(repoId: string, opts: {} = {}) { export async function getRepository(repoId: string, _opts: {} = {}) {
if (!repoId || repoId == "undefined") { if (!repoId || repoId == "undefined") {
throw new AnonymousError("repo_not_found", { throw new AnonymousError("repo_not_found", {
object: repoId, object: repoId,
+6 -6
View File
@@ -89,20 +89,20 @@ export default async function start() {
sendCommand: (...args: string[]) => redisClient.sendCommand(args), sendCommand: (...args: string[]) => redisClient.sendCommand(args),
}), }),
windowMs: 15 * 60 * 1000, // 15 minutes windowMs: 15 * 60 * 1000, // 15 minutes
skip: async (request: express.Request, response: express.Response) => { skip: async (request: express.Request, _response: express.Response) => {
try { try {
const user = await getUser(request); const user = await getUser(request);
if (user && user.isAdmin) return true; if (user && user.isAdmin) return true;
} catch (_) { } catch {
// ignore: user not connected // ignore: user not connected
} }
return false; return false;
}, },
max: async (request: express.Request, response: express.Response) => { max: async (request: express.Request, _response: express.Response) => {
try { try {
const user = await getUser(request); const user = await getUser(request);
if (user) return config.RATE_LIMIT; if (user) return config.RATE_LIMIT;
} catch (_) { } catch {
// ignore: user not connected // ignore: user not connected
} }
// if not logged in, limit to half the rate // if not logged in, limit to half the rate
@@ -111,7 +111,7 @@ export default async function start() {
keyGenerator, keyGenerator,
standardHeaders: true, standardHeaders: true,
legacyHeaders: false, legacyHeaders: false,
message: (request: express.Request, response: express.Response) => { message: (_request: express.Request, _response: express.Response) => {
return `You can only make ${config.RATE_LIMIT} requests every 15min. Please try again later.`; return `You can only make ${config.RATE_LIMIT} requests every 15min. Please try again later.`;
}, },
}); });
@@ -167,7 +167,7 @@ export default async function start() {
res.sendStatus(404); res.sendStatus(404);
}); });
let stat: any = {}; let stat: Record<string, unknown> = {};
setInterval(() => { setInterval(() => {
stat = {}; stat = {};
+5 -2
View File
@@ -51,14 +51,14 @@ router.post("/queue/:name/:repo_id", async (req, res) => {
await job.retry(); await job.retry();
res.send("ok"); res.send("ok");
} catch (error) { } catch {
try { try {
if (job) { if (job) {
await job.remove(); await job.remove();
queue.add(job.name, job.data, job.opts); queue.add(job.name, job.data, job.opts);
} }
res.send("ok"); res.send("ok");
} catch (error) { } catch {
res.status(500).send("error_retrying_job"); res.status(500).send("error_retrying_job");
} }
} }
@@ -121,6 +121,7 @@ router.get("/repos", async (req, res) => {
const remove = req.query.removed == "true"; const remove = req.query.removed == "true";
const expired = req.query.expired == "true"; const expired = req.query.expired == "true";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 }; let sort: any = { _id: 1 };
if (req.query.sort) { if (req.query.sort) {
sort = {}; sort = {};
@@ -190,6 +191,7 @@ router.get("/users", async (req, res) => {
const limit = parseInt(req.query.limit as string) || 10; const limit = parseInt(req.query.limit as string) || 10;
const skipIndex = (page - 1) * limit; const skipIndex = (page - 1) * limit;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 }; let sort: any = { _id: 1 };
if (req.query.sort) { if (req.query.sort) {
sort = {}; sort = {};
@@ -260,6 +262,7 @@ router.get("/conferences", async (req, res) => {
const limit = parseInt(req.query.limit as string) || 10; const limit = parseInt(req.query.limit as string) || 10;
const skipIndex = (page - 1) * limit; const skipIndex = (page - 1) * limit;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 }; let sort: any = { _id: 1 };
if (req.query.sort) { if (req.query.sort) {
sort = {}; sort = {};
+3 -1
View File
@@ -67,6 +67,7 @@ router.get("/", async (req: express.Request, res: express.Response) => {
} }
}); });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateConferenceForm(conf: any) { function validateConferenceForm(conf: any) {
if (!conf.name) if (!conf.name)
throw new AnonymousError("conf_name_missing", { throw new AnonymousError("conf_name_missing", {
@@ -237,12 +238,13 @@ router.get(
const conference = new Conference(data); const conference = new Conference(data);
try { try {
isOwnerOrAdmin(conference.ownerIDs, user); isOwnerOrAdmin(conference.ownerIDs, user);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const o: any = conference.toJSON(); const o: any = conference.toJSON();
o.repositories = (await conference.repositories()).map((r) => o.repositories = (await conference.repositories()).map((r) =>
r.toJSON() r.toJSON()
); );
res.json(o); res.json(o);
} catch (error) { } catch {
return res.json({ return res.json({
conferenceID: conference.conferenceID, conferenceID: conference.conferenceID,
name: conference.name, name: conference.name,
+1 -1
View File
@@ -29,7 +29,7 @@ const verify = async (
profile: Profile, profile: Profile,
done: OAuth2Strategy.VerifyCallback done: OAuth2Strategy.VerifyCallback
): Promise<void> => { ): Promise<void> => {
let user: IUserDocument | null = null; let user: IUserDocument | null;
try { try {
user = await UserModel.findOne({ "externalIDs.github": profile.id }); user = await UserModel.findOne({ "externalIDs.github": profile.id });
if (user) { if (user) {
+2
View File
@@ -98,6 +98,7 @@ router.get(
} }
); );
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateNewPullRequest(pullRequestUpdate: any): void { function validateNewPullRequest(pullRequestUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-_]+$/; const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if ( if (
@@ -146,6 +147,7 @@ function validateNewPullRequest(pullRequestUpdate: any): void {
function updatePullRequestModel( function updatePullRequestModel(
model: IAnonymizedPullRequestDocument, model: IAnonymizedPullRequestDocument,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pullRequestUpdate: any pullRequestUpdate: any
) { ) {
model.options = { model.options = {
+4
View File
@@ -39,6 +39,7 @@ async function getTokenForAdmin(user: User, req: express.Request) {
path: "owner", path: "owner",
model: UserModel, model: UserModel,
}); });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user: IUserDocument = existingRepo?.owner as any; const user: IUserDocument = existingRepo?.owner as any;
if (user instanceof UserModel) { if (user instanceof UserModel) {
const check = await checkToken(user.accessTokens.github); const check = await checkToken(user.accessTokens.github);
@@ -280,6 +281,7 @@ router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
} }
}); });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateNewRepo(repoUpdate: any): void { function validateNewRepo(repoUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-_]+$/; const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if ( if (
@@ -325,6 +327,7 @@ function validateNewRepo(repoUpdate: any): void {
function updateRepoModel( function updateRepoModel(
model: IAnonymizedRepositoryDocument, model: IAnonymizedRepositoryDocument,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
repoUpdate: any repoUpdate: any
) { ) {
if (repoUpdate.source.type) { if (repoUpdate.source.type) {
@@ -485,6 +488,7 @@ router.post("/", async (req: express.Request, res: express.Response) => {
httpStatus: 400, httpStatus: 400,
object: repoUpdate, object: repoUpdate,
}); });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) { } catch (error: any) {
if (error.message == "repo_not_found") { if (error.message == "repo_not_found") {
// the repository does not exist yet // the repository does not exist yet
+2 -2
View File
@@ -31,7 +31,7 @@ router.get(
let user: User | undefined = undefined; let user: User | undefined = undefined;
try { try {
user = await getUser(req); user = await getUser(req);
} catch (_) {} } catch { /* not logged in */ }
let download = false; let download = false;
if ( if (
@@ -187,7 +187,7 @@ router.get(
let user: User | undefined = undefined; let user: User | undefined = undefined;
try { try {
user = await getUser(req); user = await getUser(req);
} catch (_) {} } catch { /* not logged in */ }
res.json({ res.json({
url: redirectURL, url: redirectURL,
download: download || user?.isAdmin === true, download: download || user?.isAdmin === true,
+5 -4
View File
@@ -13,8 +13,7 @@ export async function getPullRequest(
) { ) {
try { try {
const pullRequest = await db.getPullRequest(req.params.pullRequestId); const pullRequest = await db.getPullRequest(req.params.pullRequestId);
if (opt?.nocheck == true) { if (opt?.nocheck !== true) {
} else {
// redirect if the repository is expired // redirect if the repository is expired
if ( if (
pullRequest.status == "expired" && pullRequest.status == "expired" &&
@@ -44,8 +43,7 @@ export async function getRepo(
) { ) {
try { try {
const repo = await db.getRepository(req.params.repoId); const repo = await db.getRepository(req.params.repoId);
if (opt.nocheck == true) { if (opt.nocheck !== true) {
} else {
// redirect if the repository is expired // redirect if the repository is expired
if ( if (
repo.status == RepositoryStatus.EXPIRED && repo.status == RepositoryStatus.EXPIRED &&
@@ -73,6 +71,7 @@ export function isOwnerOrAdmin(authorizedUsers: string[], user: User) {
} }
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function printError(error: any, req?: express.Request) { function printError(error: any, req?: express.Request) {
if (error instanceof AnonymousError) { if (error instanceof AnonymousError) {
let message = `[ERROR] ${error.toString()} ${error.stack let message = `[ERROR] ${error.toString()} ${error.stack
@@ -97,6 +96,7 @@ function printError(error: any, req?: express.Request) {
} }
export function handleError( export function handleError(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any, error: any,
res?: express.Response, res?: express.Response,
req?: express.Request req?: express.Request
@@ -139,6 +139,7 @@ export async function getUser(req: express.Request) {
if (!req.user) { if (!req.user) {
notConnected(); notConnected();
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user = (req.user as any).user; const user = (req.user as any).user;
if (!user) { if (!user) {
notConnected(); notConnected();
+1 -1
View File
@@ -88,7 +88,7 @@ async function webView(req: express.Request, res: express.Response) {
let info: IFile | null = null; let info: IFile | null = null;
try { try {
info = await f.getFileInfo(); info = await f.getFileInfo();
} catch (error) {} } catch { /* ignored */ }
if ( if (
req.headers.accept?.includes("text/html") && req.headers.accept?.includes("text/html") &&
(filePath == "" || (info && info.size == null)) (filePath == "" || (info && info.size == null))
+3 -3
View File
@@ -6,7 +6,7 @@ import Repository from "../core/Repository";
export function conferenceStatusCheck() { export function conferenceStatusCheck() {
// check every 6 hours the status of the conferences // check every 6 hours the status of the conferences
const job = schedule.scheduleJob("0 */6 * * *", async () => { schedule.scheduleJob("0 */6 * * *", async () => {
(await ConferenceModel.find({ status: { $eq: "ready" } })).forEach( (await ConferenceModel.find({ status: { $eq: "ready" } })).forEach(
async (data) => { async (data) => {
const conference = new Conference(data); const conference = new Conference(data);
@@ -24,7 +24,7 @@ export function conferenceStatusCheck() {
export function repositoryStatusCheck() { export function repositoryStatusCheck() {
// check every 6 hours the status of the repositories // check every 6 hours the status of the repositories
const job = schedule.scheduleJob("0 */6 * * *", async () => { schedule.scheduleJob("0 */6 * * *", async () => {
console.log("[schedule] Check repository status and unused repositories"); console.log("[schedule] Check repository status and unused repositories");
( (
await AnonymizedRepositoryModel.find({ await AnonymizedRepositoryModel.find({
@@ -35,7 +35,7 @@ export function repositoryStatusCheck() {
const repo = new Repository(data); const repo = new Repository(data);
try { try {
repo.check(); repo.check();
} catch (error) { } catch {
console.log(`Repository ${repo.repoId} is expired`); console.log(`Repository ${repo.repoId} is expired`);
} }
const fourMonthAgo = new Date(); const fourMonthAgo = new Date();
+4 -8
View File
@@ -1,5 +1,3 @@
import { promisify } from "util";
import * as stream from "stream";
import * as express from "express"; import * as express from "express";
import GitHubStream from "../core/source/GitHubStream"; import GitHubStream from "../core/source/GitHubStream";
import { import {
@@ -22,7 +20,6 @@ router.post(
const token: string = req.body.token; const token: string = req.body.token;
const repoFullName = req.body.repoFullName.split("/"); const repoFullName = req.body.repoFullName.split("/");
const repoId = req.body.repoId; const repoId = req.body.repoId;
const branch = req.body.branch;
const commit = req.body.commit; const commit = req.body.commit;
const anonymizerOptions = req.body.anonymizerOptions; const anonymizerOptions = req.body.anonymizerOptions;
@@ -52,12 +49,12 @@ router.post(
console.error(error); console.error(error);
try { try {
archive.finalize(); archive.finalize();
} catch (error) {} } catch { /* ignored */ }
}) })
.on("close", () => { .on("close", () => {
try { try {
archive.finalize(); archive.finalize();
} catch (error) {} } catch { /* ignored */ }
}) })
.pipe(Parse()) .pipe(Parse())
.on("entry", (entry) => { .on("entry", (entry) => {
@@ -83,12 +80,12 @@ router.post(
console.error(error); console.error(error);
try { try {
archive.finalize(); archive.finalize();
} catch (error) {} } catch { /* ignored */ }
}) })
.on("finish", () => { .on("finish", () => {
try { try {
archive.finalize(); archive.finalize();
} catch (error) {} } catch { /* ignored */ }
}); });
archive.pipe(res).on("error", (error) => { archive.pipe(res).on("error", (error) => {
console.error(error); console.error(error);
@@ -104,7 +101,6 @@ router.post("/", async (req: express.Request, res: express.Response) => {
const token: string = req.body.token; const token: string = req.body.token;
const repoFullName = req.body.repoFullName.split("/"); const repoFullName = req.body.repoFullName.split("/");
const repoId = req.body.repoId; const repoId = req.body.repoId;
const branch = req.body.branch;
const fileSha = req.body.sha; const fileSha = req.body.sha;
const commit = req.body.commit; const commit = req.body.commit;
const filePath = req.body.filePath; const filePath = req.body.filePath;