chore(routes): fix no-explicit-any lint/ts error for catch blocks

This commit is contained in:
Panagiotis Papadopoulos 2025-03-08 16:01:53 +01:00
parent 272d7cd652
commit e3d0c53d03
5 changed files with 11 additions and 8 deletions

View File

@ -33,8 +33,11 @@ async function exec(req: Request) {
executionResult: result,
maxEntityChangeId: syncService.getMaxEntityChangeId()
};
} catch (e: any) {
return { success: false, error: e.message };
} catch (e: unknown) {
return {
success: false,
error: (e instanceof Error) ? e.message : "Unknown Error"
};
}
}

View File

@ -56,10 +56,10 @@ function execute(req: Request) {
success: true,
results
};
} catch (e: any) {
} catch (e: unknown) {
return {
success: false,
error: e.message
error: (e instanceof Error) ? e.message : "Unknown Error"
};
}
}

View File

@ -30,10 +30,10 @@ async function testSync() {
syncService.sync();
return { success: true, message: t("test_sync.successful") };
} catch (e: any) {
} catch (e: unknown) {
return {
success: false,
message: e.message
error: (e instanceof Error) ? e.message : "Unknown Error"
};
}
}

View File

@ -5,7 +5,7 @@ import express from "express";
import { isDev, isElectron } from "../services/utils.js";
import type serveStatic from "serve-static";
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => {
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => {
if (!isDev) {
options = {
maxAge: "1y",

View File

@ -477,7 +477,7 @@ function route(method: HttpMethod, path: string, middleware: express.Handler[],
if (result?.then) {
// promise
result.then((promiseResult: unknown) => handleResponse(resultHandler, req, res, promiseResult, start)).catch((e: any) => handleException(e, method, path, res));
result.then((promiseResult: unknown) => handleResponse(resultHandler, req, res, promiseResult, start)).catch((e: unknown) => handleException(e, method, path, res));
} else {
handleResponse(resultHandler, req, res, result, start);
}