From 59a08651576995ff82bf647bf5da929af91c67e1 Mon Sep 17 00:00:00 2001 From: "Chen, Tai-Lin" Date: Mon, 25 Mar 2024 14:53:44 +0800 Subject: [PATCH] reverse change --- packages/analytics/src/controllers/commands.js | 2 +- packages/analytics/src/controllers/sessions.js | 2 +- packages/analytics/src/controllers/users.js | 2 +- server/src/auth/googleStrategy.ts | 2 +- server/src/auth/passwordStrategy.ts | 4 ++-- server/src/containers/docker.ts | 4 ++-- server/src/middleware/error.ts | 7 ++----- server/src/utils/auth.ts | 2 +- server/src/utils/quest.ts | 6 +++--- 9 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/analytics/src/controllers/commands.js b/packages/analytics/src/controllers/commands.js index 293d1d4..b570504 100644 --- a/packages/analytics/src/controllers/commands.js +++ b/packages/analytics/src/controllers/commands.js @@ -17,7 +17,7 @@ export async function commandListController(req, res) { nextKey: newNextKey, order: pagination.getOrder(), }) - } catch (error: any) { + } catch (error) { console.error(error) res.status(500).send('Error fetching data') } diff --git a/packages/analytics/src/controllers/sessions.js b/packages/analytics/src/controllers/sessions.js index ef181e7..a4dbe89 100644 --- a/packages/analytics/src/controllers/sessions.js +++ b/packages/analytics/src/controllers/sessions.js @@ -15,7 +15,7 @@ export async function sessionListController(req, res) { nextKey: newNextKey, order: pagination.getOrder(), }) - } catch (error: any) { + } catch (error) { console.log(error) res.status(500).send('Error fetching session data') } diff --git a/packages/analytics/src/controllers/users.js b/packages/analytics/src/controllers/users.js index bb40260..220bb3b 100644 --- a/packages/analytics/src/controllers/users.js +++ b/packages/analytics/src/controllers/users.js @@ -15,7 +15,7 @@ export async function userListController(req, res) { nextKey: newNextKey, order: pagination.getOrder(), }) - } catch (error: any) { + } catch (error) { console.error(error) res.status(500).send('Error fetching user data') } diff --git a/server/src/auth/googleStrategy.ts b/server/src/auth/googleStrategy.ts index bcb12f1..b02912a 100644 --- a/server/src/auth/googleStrategy.ts +++ b/server/src/auth/googleStrategy.ts @@ -3,7 +3,7 @@ import { Strategy as GoogleStrategy } from 'passport-google-oidc' import config from '../config.js' import oauthVerify from './oauthVerify.js' -function verify(profile: any, cb: any) { +function verify(issuer: string, profile: any, cb: any) { oauthVerify('google', profile, { 'socialLogins.google.id': profile.id }, cb) } diff --git a/server/src/auth/passwordStrategy.ts b/server/src/auth/passwordStrategy.ts index 64c6d37..3a6aab6 100644 --- a/server/src/auth/passwordStrategy.ts +++ b/server/src/auth/passwordStrategy.ts @@ -9,7 +9,7 @@ async function verifyPassword( username: string, password: string, done: ( - error: Error | null, + error: any, user?: Express.User | false, options?: IVerifyOptions ) => void @@ -34,7 +34,7 @@ async function verifyPassword( username: user.username, email: user.email, }) - } catch (err: any) { + } catch (err) { return done(err) } } diff --git a/server/src/containers/docker.ts b/server/src/containers/docker.ts index 3f96968..a29fd85 100644 --- a/server/src/containers/docker.ts +++ b/server/src/containers/docker.ts @@ -82,7 +82,7 @@ export async function deleteContainer(id: string) { } try { await container.stop() - } catch (error: any) { + } catch (error) { logger.warn('Failed to stop container', id) } await container.remove() @@ -127,7 +127,7 @@ export function buildQuestImage(questPath: string, questId: string) { .forEach((line: string) => { parseJSONOutput(line) }) - } catch (error: any) { + } catch (error) { reject(error) } }) diff --git a/server/src/middleware/error.ts b/server/src/middleware/error.ts index f05667e..84081cf 100644 --- a/server/src/middleware/error.ts +++ b/server/src/middleware/error.ts @@ -1,10 +1,7 @@ import type { Request, Response, NextFunction } from 'express' import logger from '../utils/logger.js' -export function asyncHandler( - // eslint-disable-next-line no-unused-vars - fn: (req: Request, res: Response, next: NextFunction) => Promise -) { +export function asyncHandler(fn: any) { return (req: Request, res: Response, next: NextFunction) => { fn(req, res, next).catch(next) } @@ -12,7 +9,7 @@ export function asyncHandler( // eslint-disable-next-line no-unused-vars export default function errorHandler( - err: Error, + err: any, req: Request, res: Response, // eslint-disable-next-line no-unused-vars diff --git a/server/src/utils/auth.ts b/server/src/utils/auth.ts index f381e74..751ae8f 100644 --- a/server/src/utils/auth.ts +++ b/server/src/utils/auth.ts @@ -6,7 +6,7 @@ export function hashPassword(password: string): Promise { return bcrypt.hash(password, 10) } -export function genJWT(payload: { [key: string]: string }): Promise { +export function genJWT(payload: any): Promise { return new Promise((resolve, reject) => { jwt.sign( payload, diff --git a/server/src/utils/quest.ts b/server/src/utils/quest.ts index 7035830..9fda0b6 100644 --- a/server/src/utils/quest.ts +++ b/server/src/utils/quest.ts @@ -9,9 +9,9 @@ const questDirectory = path.join(process.cwd(), '..', 'quests') class QuestValidationError extends Error { questId: string - error: Error | null + error: any - constructor(message: string, questId: string, error: Error | null) { + constructor(message: string, questId: string, error: any) { super(message) this.name = 'QuestValidationError' this.questId = questId @@ -68,7 +68,7 @@ export async function loadAndUpdateQuests() { }) quest.exceptions.push(...exceptions) await quest.save() - } catch (error: any) { + } catch (error) { logger.error(`Error parsing quest`, { id, error }) throw new QuestValidationError(`Error parsing quest`, id, error) }