diff --git a/server/eslint.config.js b/server/eslint.config.js index 4e45d6157..817f54bc2 100755 --- a/server/eslint.config.js +++ b/server/eslint.config.js @@ -32,7 +32,9 @@ export default [ languageOptions: { parser: tseslint.parser, parserOptions: { - projectService: true, + projectService: { + allowDefaultProject: ["jest.config.ts"], + }, tsconfigRootDir: import.meta.dirname, }, }, diff --git a/server/src/app.ts b/server/src/app.ts index 58684532c..da1cd8ad9 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -4,7 +4,7 @@ import cors from "cors"; import helmet from "helmet"; import compression from "compression"; import cookieParser from "cookie-parser"; -import swaggerUi from "swagger-ui-express"; +import swaggerUi, { type JsonObject } from "swagger-ui-express"; import { handleErrors } from "@/middleware/handleErrors.js"; import { generalApiLimiter } from "@/middleware/rateLimiter.js"; import { sanitizeBody, sanitizeQuery } from "@/middleware/sanitization.js"; @@ -24,7 +24,7 @@ export const createApp = ({ controllers: InitializedControllers; envSettings: EnvConfig; frontendPath: string; - openApiSpec: any; + openApiSpec: JsonObject; }) => { const allowedOrigin = envSettings.clientHost; const app = express(); diff --git a/server/src/config/routes.ts b/server/src/config/routes.ts index 672866dc1..f36f56e16 100644 --- a/server/src/config/routes.ts +++ b/server/src/config/routes.ts @@ -1,6 +1,9 @@ +import type { Application } from "express"; import { createVerifyJWT } from "../middleware/verifyJWT.js"; import { createVerifyStatusPageAccess } from "../middleware/verifyStatusPageAccess.js"; import { authApiLimiter } from "../middleware/rateLimiter.js"; +import type { InitializedControllers } from "./controllers.js"; +import type { InitializedServices } from "./services.js"; import AuthRoutes from "../routes/authRoute.js"; import InviteRoutes from "../routes/inviteRoute.js"; @@ -17,7 +20,7 @@ import NotificationRoutes from "../routes/notificationRoute.js"; import IncidentRoutes from "../routes/incidentRoute.js"; -export const setupRoutes = (app: any, controllers: Record, services: Record) => { +export const setupRoutes = (app: Application, controllers: InitializedControllers, services: InitializedServices) => { const verifyJWT = createVerifyJWT(services.settingsService); const authRoutes = new AuthRoutes(controllers.authController, verifyJWT); const monitorRoutes = new MonitorRoutes(controllers.monitorController); diff --git a/server/src/controllers/settingsController.ts b/server/src/controllers/settingsController.ts index ca011889f..03bc91898 100644 --- a/server/src/controllers/settingsController.ts +++ b/server/src/controllers/settingsController.ts @@ -3,6 +3,7 @@ import { updateAppSettingsBodyValidation } from "@/validation/settingsValidation import { sendTestEmailBodyValidation } from "@/validation/notificationValidation.js"; import { AppError } from "@/utils/AppError.js"; import { IEmailService, ISettingsService } from "@/service/index.js"; +import { Settings } from "@/types/settings.js"; const SERVICE_NAME = "SettingsController"; @@ -26,11 +27,11 @@ class SettingsController implements ISettingsController { return SettingsController.SERVICE_NAME; } - buildAppSettings = (dbSettings: any) => { - const sanitizedSettings = { ...dbSettings }; + buildAppSettings = (dbSettings: Settings) => { + const sanitizedSettings: Record = { ...dbSettings }; delete sanitizedSettings.version; delete sanitizedSettings.jwtSecret; - const returnSettings = { + const returnSettings: Record = { pagespeedKeySet: false, emailPasswordSet: false, settings: null, diff --git a/server/src/middleware/verifyJWT.ts b/server/src/middleware/verifyJWT.ts index 4bec4c077..63218566c 100644 --- a/server/src/middleware/verifyJWT.ts +++ b/server/src/middleware/verifyJWT.ts @@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from "express"; import jwt from "jsonwebtoken"; import { AppError } from "@/utils/AppError.js"; -import { Settings } from "@/types/settings.js"; +import type { ISettingsService } from "@/service/system/settingsService.js"; import type { User } from "@/types/user.js"; const SERVICE_NAME = "verifyJWT"; @@ -12,7 +12,7 @@ const isUser = (payload: unknown): payload is User => { return typeof payload === "object" && payload !== null && "id" in payload && "teamId" in payload && "role" in payload; }; -export const createVerifyJWT = (settingsService: { getSettings: () => Settings }) => { +export const createVerifyJWT = (settingsService: ISettingsService) => { return (req: Request, res: Response, next: NextFunction) => { const token = req.headers["authorization"]; // Make sure a token is provided