diff --git a/services/web/app.mjs b/services/web/app.mjs index 9103dc3d4e..5de7ee17e2 100644 --- a/services/web/app.mjs +++ b/services/web/app.mjs @@ -1,7 +1,7 @@ // Metrics must be initialized before importing anything else import { metricsModuleImportStartTime } from '@overleaf/metrics/initialize.js' -import Modules from './app/src/infrastructure/Modules.mjs' +import Modules from './app/src/infrastructure/Modules.js' import metrics from '@overleaf/metrics' import Settings from '@overleaf/settings' import logger from '@overleaf/logger' @@ -13,10 +13,10 @@ import https from 'node:https' import Serializers from './app/src/infrastructure/LoggerSerializers.mjs' import Server from './app/src/infrastructure/Server.mjs' import QueueWorkers from './app/src/infrastructure/QueueWorkers.mjs' -import mongodb from './app/src/infrastructure/mongodb.mjs' -import mongoose from './app/src/infrastructure/Mongoose.mjs' -import { triggerGracefulShutdown } from './app/src/infrastructure/GracefulShutdown.mjs' -import FileWriter from './app/src/infrastructure/FileWriter.mjs' +import mongodb from './app/src/infrastructure/mongodb.js' +import mongoose from './app/src/infrastructure/Mongoose.js' +import { triggerGracefulShutdown } from './app/src/infrastructure/GracefulShutdown.js' +import FileWriter from './app/src/infrastructure/FileWriter.js' import { fileURLToPath } from 'node:url' metrics.gauge( diff --git a/services/web/app/src/Features/Analytics/AnalyticsManager.mjs b/services/web/app/src/Features/Analytics/AnalyticsManager.mjs index c3a2c4e09c..014934905c 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsManager.mjs +++ b/services/web/app/src/Features/Analytics/AnalyticsManager.mjs @@ -1,7 +1,7 @@ import SessionManager from '../Authentication/SessionManager.mjs' import UserAnalyticsIdCache from './UserAnalyticsIdCache.mjs' import Settings from '@overleaf/settings' -import Metrics from '../../infrastructure/Metrics.mjs' +import Metrics from '../../infrastructure/Metrics.js' import Queues from '../../infrastructure/Queues.mjs' import crypto, { createHash } from 'node:crypto' import _ from 'lodash' diff --git a/services/web/app/src/Features/Analytics/AnalyticsRouter.mjs b/services/web/app/src/Features/Analytics/AnalyticsRouter.mjs index f19df459cb..161efcfcca 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsRouter.mjs +++ b/services/web/app/src/Features/Analytics/AnalyticsRouter.mjs @@ -1,7 +1,7 @@ import AuthenticationController from './../Authentication/AuthenticationController.mjs' import AnalyticsController from './AnalyticsController.mjs' import AnalyticsProxy from './AnalyticsProxy.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' const rateLimiters = { diff --git a/services/web/app/src/Features/Authentication/AuthenticationController.mjs b/services/web/app/src/Features/Authentication/AuthenticationController.mjs index 73af8d5058..7f6187dfc2 100644 --- a/services/web/app/src/Features/Authentication/AuthenticationController.mjs +++ b/services/web/app/src/Features/Authentication/AuthenticationController.mjs @@ -19,9 +19,9 @@ import AsyncFormHelper from '../Helpers/AsyncFormHelper.mjs' import _ from 'lodash' import UserAuditLogHandler from '../User/UserAuditLogHandler.mjs' import AnalyticsRegistrationSourceHelper from '../Analytics/AnalyticsRegistrationSourceHelper.mjs' -import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.js' import AdminAuthorizationHelper from '../Helpers/AdminAuthorizationHelper.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { expressify, promisify } from '@overleaf/promise-utils' import { handleAuthenticateErrors } from './AuthenticationErrors.mjs' import EmailHelper from '../Helpers/EmailHelper.mjs' diff --git a/services/web/app/src/Features/Authentication/AuthenticationManager.mjs b/services/web/app/src/Features/Authentication/AuthenticationManager.mjs index e49c5be410..ab24e0e41e 100644 --- a/services/web/app/src/Features/Authentication/AuthenticationManager.mjs +++ b/services/web/app/src/Features/Authentication/AuthenticationManager.mjs @@ -1,6 +1,6 @@ import Settings from '@overleaf/settings' import { User } from '../../models/User.mjs' -import { db, ObjectId } from '../../infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../infrastructure/mongodb.js' import bcrypt from 'bcrypt' import EmailHelper from '../Helpers/EmailHelper.mjs' diff --git a/services/web/app/src/Features/Authorization/PermissionsController.mjs b/services/web/app/src/Features/Authorization/PermissionsController.mjs index 29b3ef4ae2..9dd6bf6300 100644 --- a/services/web/app/src/Features/Authorization/PermissionsController.mjs +++ b/services/web/app/src/Features/Authorization/PermissionsController.mjs @@ -1,7 +1,7 @@ // @ts-check import { ForbiddenError, UserNotFoundError } from '../Errors/Errors.js' import PermissionsManager from './PermissionsManager.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { expressify } from '@overleaf/promise-utils' import Features from '../../infrastructure/Features.mjs' diff --git a/services/web/app/src/Features/Authorization/PermissionsManager.mjs b/services/web/app/src/Features/Authorization/PermissionsManager.mjs index f35d8c4469..5924750f9e 100644 --- a/services/web/app/src/Features/Authorization/PermissionsManager.mjs +++ b/services/web/app/src/Features/Authorization/PermissionsManager.mjs @@ -44,7 +44,7 @@ import { callbackify } from 'node:util' import Errors from '../Errors/Errors.js' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' const { ForbiddenError } = Errors diff --git a/services/web/app/src/Features/Chat/ChatController.mjs b/services/web/app/src/Features/Chat/ChatController.mjs index 3cbd7e0132..569fa56597 100644 --- a/services/web/app/src/Features/Chat/ChatController.mjs +++ b/services/web/app/src/Features/Chat/ChatController.mjs @@ -1,5 +1,5 @@ import { expressify } from '@overleaf/promise-utils' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import ChatApiHandler from './ChatApiHandler.mjs' import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs' import SessionManager from '../Authentication/SessionManager.mjs' diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs index cf31f5804e..b70553218e 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs @@ -15,7 +15,7 @@ import TokenAccessHandler from '../TokenAccess/TokenAccessHandler.mjs' import ProjectAuditLogHandler from '../Project/ProjectAuditLogHandler.mjs' import LimitationsManager from '../Subscription/LimitationsManager.mjs' import PrivilegeLevels from '../Authorization/PrivilegeLevels.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' import Features from '../../infrastructure/Features.mjs' const { hasAdminAccess } = AdminAuthorizationHelper diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs index 06e4e3a55e..aca557934a 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs @@ -10,8 +10,8 @@ import EmailHelper from '../Helpers/EmailHelper.mjs' import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs' import AnalyticsManager from '../Analytics/AnalyticsManager.mjs' import SessionManager from '../Authentication/SessionManager.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' import { expressify } from '@overleaf/promise-utils' import ProjectAuditLogHandler from '../Project/ProjectAuditLogHandler.mjs' import Errors from '../Errors/Errors.js' diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsRouter.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsRouter.mjs index 6b4ead8cac..394cae6453 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsRouter.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsRouter.mjs @@ -2,7 +2,7 @@ import CollaboratorsController from './CollaboratorsController.mjs' import AuthenticationController from '../Authentication/AuthenticationController.mjs' import AuthorizationMiddleware from '../Authorization/AuthorizationMiddleware.mjs' import CollaboratorsInviteController from './CollaboratorsInviteController.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' import CaptchaMiddleware from '../Captcha/CaptchaMiddleware.mjs' import AnalyticsRegistrationSourceMiddleware from '../Analytics/AnalyticsRegistrationSourceMiddleware.mjs' diff --git a/services/web/app/src/Features/Compile/ClsiCookieManager.mjs b/services/web/app/src/Features/Compile/ClsiCookieManager.mjs index 7ccb1c9ba3..cc21fcd09a 100644 --- a/services/web/app/src/Features/Compile/ClsiCookieManager.mjs +++ b/services/web/app/src/Features/Compile/ClsiCookieManager.mjs @@ -6,7 +6,7 @@ import { fetchStringWithResponse, RequestFailedError, } from '@overleaf/fetch-utils' -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' import Cookie from 'cookie' import logger from '@overleaf/logger' import Metrics from '@overleaf/metrics' diff --git a/services/web/app/src/Features/Compile/CompileController.mjs b/services/web/app/src/Features/Compile/CompileController.mjs index c4ba3050a8..f1a3a6e8fc 100644 --- a/services/web/app/src/Features/Compile/CompileController.mjs +++ b/services/web/app/src/Features/Compile/CompileController.mjs @@ -10,8 +10,8 @@ import logger from '@overleaf/logger' import Settings from '@overleaf/settings' import Errors from '../Errors/Errors.js' import SessionManager from '../Authentication/SessionManager.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' -import Validation from '../../infrastructure/Validation.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' +import Validation from '../../infrastructure/Validation.js' import ClsiCookieManagerFactory from './ClsiCookieManager.mjs' import Path from 'node:path' import AnalyticsManager from '../Analytics/AnalyticsManager.mjs' diff --git a/services/web/app/src/Features/Compile/CompileManager.mjs b/services/web/app/src/Features/Compile/CompileManager.mjs index e1629f4871..c951326fc4 100644 --- a/services/web/app/src/Features/Compile/CompileManager.mjs +++ b/services/web/app/src/Features/Compile/CompileManager.mjs @@ -1,12 +1,12 @@ import Crypto from 'node:crypto' import Settings from '@overleaf/settings' -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' import ProjectGetter from '../Project/ProjectGetter.mjs' import ProjectRootDocManager from '../Project/ProjectRootDocManager.mjs' import UserGetter from '../User/UserGetter.mjs' import ClsiManager from './ClsiManager.mjs' import Metrics from '@overleaf/metrics' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import UserAnalyticsIdCache from '../Analytics/UserAnalyticsIdCache.mjs' import { callbackify, callbackifyMultiResult } from '@overleaf/promise-utils' let CompileManager diff --git a/services/web/app/src/Features/Contacts/ContactController.mjs b/services/web/app/src/Features/Contacts/ContactController.mjs index 5673d0be2d..7b02318d91 100644 --- a/services/web/app/src/Features/Contacts/ContactController.mjs +++ b/services/web/app/src/Features/Contacts/ContactController.mjs @@ -1,7 +1,7 @@ import SessionManager from '../Authentication/SessionManager.mjs' import ContactManager from './ContactManager.mjs' import UserGetter from '../User/UserGetter.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { expressify } from '@overleaf/promise-utils' function _formatContact(contact) { diff --git a/services/web/app/src/Features/Cooldown/CooldownManager.mjs b/services/web/app/src/Features/Cooldown/CooldownManager.mjs index 0d7eb28f29..5f190d1a08 100644 --- a/services/web/app/src/Features/Cooldown/CooldownManager.mjs +++ b/services/web/app/src/Features/Cooldown/CooldownManager.mjs @@ -1,4 +1,4 @@ -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' import logger from '@overleaf/logger' import { promisify } from '@overleaf/promise-utils' const rclient = RedisWrapper.client('cooldown') diff --git a/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs b/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs index 4de5446a31..bd35f93b4d 100644 --- a/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs +++ b/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs @@ -1,7 +1,7 @@ import logger from '@overleaf/logger' import DocumentUpdaterHandler from './DocumentUpdaterHandler.mjs' import ProjectLocator from '../Project/ProjectLocator.mjs' -import { plainTextResponse } from '../../infrastructure/Response.mjs' +import { plainTextResponse } from '../../infrastructure/Response.js' import { expressify } from '@overleaf/promise-utils' async function getDoc(req, res) { diff --git a/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs b/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs index c9cc737b46..cf9b36de75 100644 --- a/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs +++ b/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs @@ -10,7 +10,7 @@ import _ from 'lodash' import logger from '@overleaf/logger' import { callbackifyAll } from '@overleaf/promise-utils' import ProjectGetter from '../Project/ProjectGetter.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' const REQUEST_TIMEOUT_MS = 30 * 1000 const RESYNC_TIMEOUT_MS = 6 * 60 * 1000 diff --git a/services/web/app/src/Features/Documents/DocumentController.mjs b/services/web/app/src/Features/Documents/DocumentController.mjs index 764c2efbca..399240d53a 100644 --- a/services/web/app/src/Features/Documents/DocumentController.mjs +++ b/services/web/app/src/Features/Documents/DocumentController.mjs @@ -5,9 +5,9 @@ import ProjectEntityHandler from '../Project/ProjectEntityHandler.mjs' import ProjectEntityUpdateHandler from '../Project/ProjectEntityUpdateHandler.mjs' import logger from '@overleaf/logger' import _ from 'lodash' -import { plainTextResponse } from '../../infrastructure/Response.mjs' +import { plainTextResponse } from '../../infrastructure/Response.js' import { expressify } from '@overleaf/promise-utils' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' async function getDocument(req, res) { const { Project_id: projectId, doc_id: docId } = req.params diff --git a/services/web/app/src/Features/Downloads/ProjectDownloadsController.mjs b/services/web/app/src/Features/Downloads/ProjectDownloadsController.mjs index adea09f9a6..42dcffcd4f 100644 --- a/services/web/app/src/Features/Downloads/ProjectDownloadsController.mjs +++ b/services/web/app/src/Features/Downloads/ProjectDownloadsController.mjs @@ -14,7 +14,7 @@ import Metrics from '@overleaf/metrics' import ProjectGetter from '../Project/ProjectGetter.mjs' import ProjectZipStreamManager from './ProjectZipStreamManager.mjs' import DocumentUpdaterHandler from '../DocumentUpdater/DocumentUpdaterHandler.mjs' -import { prepareZipAttachment } from '../../infrastructure/Response.mjs' +import { prepareZipAttachment } from '../../infrastructure/Response.js' let ProjectDownloadsController diff --git a/services/web/app/src/Features/Editor/EditorHttpController.mjs b/services/web/app/src/Features/Editor/EditorHttpController.mjs index aefe529e05..9fe2550e4e 100644 --- a/services/web/app/src/Features/Editor/EditorHttpController.mjs +++ b/services/web/app/src/Features/Editor/EditorHttpController.mjs @@ -11,7 +11,7 @@ import Errors from '../Errors/Errors.js' import { expressify } from '@overleaf/promise-utils' import Settings from '@overleaf/settings' import CollaboratorsGetter from '../Collaborators/CollaboratorsGetter.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' const ProjectAccess = CollaboratorsGetter.ProjectAccess diff --git a/services/web/app/src/Features/Editor/EditorRealTimeController.mjs b/services/web/app/src/Features/Editor/EditorRealTimeController.mjs index 46b80302df..4574e3deda 100644 --- a/services/web/app/src/Features/Editor/EditorRealTimeController.mjs +++ b/services/web/app/src/Features/Editor/EditorRealTimeController.mjs @@ -12,7 +12,7 @@ */ import Settings from '@overleaf/settings' import Metrics from '@overleaf/metrics' -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' import os from 'node:os' import crypto from 'node:crypto' let EditorRealTimeController diff --git a/services/web/app/src/Features/Editor/EditorRouter.mjs b/services/web/app/src/Features/Editor/EditorRouter.mjs index 09833221a4..908fef0ab7 100644 --- a/services/web/app/src/Features/Editor/EditorRouter.mjs +++ b/services/web/app/src/Features/Editor/EditorRouter.mjs @@ -1,7 +1,7 @@ import EditorHttpController from './EditorHttpController.mjs' import AuthenticationController from '../Authentication/AuthenticationController.mjs' import AuthorizationMiddleware from '../Authorization/AuthorizationMiddleware.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' const rateLimiters = { diff --git a/services/web/app/src/Features/Email/EmailSender.mjs b/services/web/app/src/Features/Email/EmailSender.mjs index c960a4949a..da32ebee8f 100644 --- a/services/web/app/src/Features/Email/EmailSender.mjs +++ b/services/web/app/src/Features/Email/EmailSender.mjs @@ -5,7 +5,7 @@ import Settings from '@overleaf/settings' import nodemailer from 'nodemailer' import aws from '@aws-sdk/client-ses' import OError from '@overleaf/o-error' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import _ from 'lodash' const EMAIL_SETTINGS = Settings.email || {} diff --git a/services/web/app/src/Features/Errors/ErrorController.mjs b/services/web/app/src/Features/Errors/ErrorController.mjs index bc95b90128..25b297eb0e 100644 --- a/services/web/app/src/Features/Errors/ErrorController.mjs +++ b/services/web/app/src/Features/Errors/ErrorController.mjs @@ -3,7 +3,7 @@ import Errors from './Errors.js' import SessionManager from '../Authentication/SessionManager.mjs' import SamlLogHandler from '../SamlLog/SamlLogHandler.mjs' import HttpErrorHandler from './HttpErrorHandler.mjs' -import { plainTextResponse } from '../../infrastructure/Response.mjs' +import { plainTextResponse } from '../../infrastructure/Response.js' import { expressifyErrorHandler } from '@overleaf/promise-utils' function notFound(req, res) { diff --git a/services/web/app/src/Features/Errors/HttpErrorHandler.mjs b/services/web/app/src/Features/Errors/HttpErrorHandler.mjs index 07745dd3bb..5f8b348310 100644 --- a/services/web/app/src/Features/Errors/HttpErrorHandler.mjs +++ b/services/web/app/src/Features/Errors/HttpErrorHandler.mjs @@ -1,6 +1,6 @@ import logger from '@overleaf/logger' import Settings from '@overleaf/settings' -import { plainTextResponse } from '../../infrastructure/Response.mjs' +import { plainTextResponse } from '../../infrastructure/Response.js' function renderJSONError(res, message, info = {}) { if (info.message) { diff --git a/services/web/app/src/Features/FileStore/FileStoreController.mjs b/services/web/app/src/Features/FileStore/FileStoreController.mjs index 0d1ea402d1..252485cf49 100644 --- a/services/web/app/src/Features/FileStore/FileStoreController.mjs +++ b/services/web/app/src/Features/FileStore/FileStoreController.mjs @@ -7,7 +7,7 @@ import Metrics from '@overleaf/metrics' import ProjectLocator from '../Project/ProjectLocator.mjs' import HistoryManager from '../History/HistoryManager.mjs' import Errors from '../Errors/Errors.js' -import { preparePlainTextResponse } from '../../infrastructure/Response.mjs' +import { preparePlainTextResponse } from '../../infrastructure/Response.js' async function getFile(req, res) { const projectId = req.params.Project_id diff --git a/services/web/app/src/Features/FileStore/FileStoreHandler.mjs b/services/web/app/src/Features/FileStore/FileStoreHandler.mjs index 51612969f7..6abc6602b9 100644 --- a/services/web/app/src/Features/FileStore/FileStoreHandler.mjs +++ b/services/web/app/src/Features/FileStore/FileStoreHandler.mjs @@ -7,7 +7,7 @@ import ProjectDetailsHandler from '../Project/ProjectDetailsHandler.mjs' import { File } from '../../models/File.mjs' import OError from '@overleaf/o-error' import { promisifyAll } from '@overleaf/promise-utils' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' const FileStoreHandler = { RETRY_ATTEMPTS: 3, diff --git a/services/web/app/src/Features/HealthCheck/HealthCheckController.mjs b/services/web/app/src/Features/HealthCheck/HealthCheckController.mjs index 853da549b6..238efa2f1e 100644 --- a/services/web/app/src/Features/HealthCheck/HealthCheckController.mjs +++ b/services/web/app/src/Features/HealthCheck/HealthCheckController.mjs @@ -1,4 +1,4 @@ -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' import settings from '@overleaf/settings' import logger from '@overleaf/logger' import UserGetter from '../User/UserGetter.mjs' diff --git a/services/web/app/src/Features/Helpers/AdminAuthorizationHelper.mjs b/services/web/app/src/Features/Helpers/AdminAuthorizationHelper.mjs index 0e10abb04f..6a7fde9d79 100644 --- a/services/web/app/src/Features/Helpers/AdminAuthorizationHelper.mjs +++ b/services/web/app/src/Features/Helpers/AdminAuthorizationHelper.mjs @@ -1,5 +1,5 @@ import Settings from '@overleaf/settings' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { expressify } from '@overleaf/promise-utils' import SessionManager from '../Authentication/SessionManager.mjs' import logger from '@overleaf/logger' diff --git a/services/web/app/src/Features/Helpers/AsyncFormHelper.mjs b/services/web/app/src/Features/Helpers/AsyncFormHelper.mjs index c74a9c24da..3365c22646 100644 --- a/services/web/app/src/Features/Helpers/AsyncFormHelper.mjs +++ b/services/web/app/src/Features/Helpers/AsyncFormHelper.mjs @@ -1,4 +1,4 @@ -import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.js' export default { redirect, diff --git a/services/web/app/src/Features/History/HistoryController.mjs b/services/web/app/src/Features/History/HistoryController.mjs index e0cf991bdf..d78ab0cb1a 100644 --- a/services/web/app/src/Features/History/HistoryController.mjs +++ b/services/web/app/src/Features/History/HistoryController.mjs @@ -23,9 +23,9 @@ import HistoryManager from './HistoryManager.mjs' import ProjectDetailsHandler from '../Project/ProjectDetailsHandler.mjs' import ProjectEntityUpdateHandler from '../Project/ProjectEntityUpdateHandler.mjs' import RestoreManager from './RestoreManager.mjs' -import { prepareZipAttachment } from '../../infrastructure/Response.mjs' +import { prepareZipAttachment } from '../../infrastructure/Response.js' import Features from '../../infrastructure/Features.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' // Number of seconds after which the browser should send a request to revalidate // blobs diff --git a/services/web/app/src/Features/History/HistoryManager.mjs b/services/web/app/src/Features/History/HistoryManager.mjs index 9e77d95d9a..ccb17fd277 100644 --- a/services/web/app/src/Features/History/HistoryManager.mjs +++ b/services/web/app/src/Features/History/HistoryManager.mjs @@ -11,7 +11,7 @@ import OError from '@overleaf/o-error' import UserGetter from '../User/UserGetter.mjs' import ProjectGetter from '../Project/ProjectGetter.mjs' import HistoryBackupDeletionHandler from './HistoryBackupDeletionHandler.mjs' -import { db, waitForDb } from '../../infrastructure/mongodb.mjs' +import { db, waitForDb } from '../../infrastructure/mongodb.js' import Metrics from '@overleaf/metrics' import { NotFoundError } from '../Errors/Errors.js' diff --git a/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs b/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs index b57ff81fc3..76dcdb17a5 100644 --- a/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs +++ b/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs @@ -7,7 +7,7 @@ import HistoryManager from '../History/HistoryManager.mjs' import DocumentUpdaterHandler from '../DocumentUpdater/DocumentUpdaterHandler.mjs' import DocstoreManager from '../Docstore/DocstoreManager.mjs' import ProjectOptionsHandler from '../Project/ProjectOptionsHandler.mjs' -import mongodb from '../../infrastructure/mongodb.mjs' +import mongodb from '../../infrastructure/mongodb.js' const { db, ObjectId, READ_PREFERENCE_SECONDARY } = mongodb diff --git a/services/web/app/src/Features/History/HistoryRouter.mjs b/services/web/app/src/Features/History/HistoryRouter.mjs index abf43eb486..f1e1f187b2 100644 --- a/services/web/app/src/Features/History/HistoryRouter.mjs +++ b/services/web/app/src/Features/History/HistoryRouter.mjs @@ -1,7 +1,7 @@ // @ts-check import Settings from '@overleaf/settings' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import AuthenticationController from '../Authentication/AuthenticationController.mjs' import AuthorizationMiddleware from '../Authorization/AuthorizationMiddleware.mjs' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' diff --git a/services/web/app/src/Features/History/RestoreManager.mjs b/services/web/app/src/Features/History/RestoreManager.mjs index dfa2118453..c758b97c5b 100644 --- a/services/web/app/src/Features/History/RestoreManager.mjs +++ b/services/web/app/src/Features/History/RestoreManager.mjs @@ -1,7 +1,7 @@ import Settings from '@overleaf/settings' import Path from 'node:path' -import FileWriter from '../../infrastructure/FileWriter.mjs' -import Metrics from '../../infrastructure/Metrics.mjs' +import FileWriter from '../../infrastructure/FileWriter.js' +import Metrics from '../../infrastructure/Metrics.js' import FileSystemImportManager from '../Uploads/FileSystemImportManager.mjs' import FileTypeManager from '../Uploads/FileTypeManager.mjs' import EditorController from '../Editor/EditorController.mjs' diff --git a/services/web/app/src/Features/InactiveData/InactiveProjectManager.mjs b/services/web/app/src/Features/InactiveData/InactiveProjectManager.mjs index 53f9f569e5..be91231fd3 100644 --- a/services/web/app/src/Features/InactiveData/InactiveProjectManager.mjs +++ b/services/web/app/src/Features/InactiveData/InactiveProjectManager.mjs @@ -5,8 +5,8 @@ import DocumentUpdaterHandler from '../DocumentUpdater/DocumentUpdaterHandler.mj import ProjectGetter from '../Project/ProjectGetter.mjs' import ProjectUpdateHandler from '../Project/ProjectUpdateHandler.mjs' import { Project } from '../../models/Project.mjs' -import Modules from '../../infrastructure/Modules.mjs' -import { READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.mjs' +import Modules from '../../infrastructure/Modules.js' +import { READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.js' import { callbackifyAll } from '@overleaf/promise-utils' import Metrics from '@overleaf/metrics' diff --git a/services/web/app/src/Features/Institutions/InstitutionsAPI.mjs b/services/web/app/src/Features/Institutions/InstitutionsAPI.mjs index dbf25a77f3..8400cdfa83 100644 --- a/services/web/app/src/Features/Institutions/InstitutionsAPI.mjs +++ b/services/web/app/src/Features/Institutions/InstitutionsAPI.mjs @@ -10,7 +10,7 @@ import { InvalidInstitutionalEmailError, } from '../Errors/Errors.js' import { fetchJson, fetchNothing } from '@overleaf/fetch-utils' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' function _makeRequestOptions(options) { const requestOptions = { diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.mjs b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.mjs index 696cbc7db5..f60be663da 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.mjs +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.mjs @@ -20,9 +20,9 @@ import { OutputFileFetchFailedError, FileTooLargeError, } from '../Errors/Errors.js' -import Modules from '../../infrastructure/Modules.mjs' -import { plainTextResponse } from '../../infrastructure/Response.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import Modules from '../../infrastructure/Modules.js' +import { plainTextResponse } from '../../infrastructure/Response.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs' import { expressify } from '@overleaf/promise-utils' import ProjectOutputFileAgent from './ProjectOutputFileAgent.mjs' diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.mjs b/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.mjs index f9c9bf81bb..4bbc9069b8 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.mjs +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.mjs @@ -1,4 +1,4 @@ -import FileWriter from '../../infrastructure/FileWriter.mjs' +import FileWriter from '../../infrastructure/FileWriter.js' import EditorController from '../Editor/EditorController.mjs' import ProjectLocator from '../Project/ProjectLocator.mjs' import { Project } from '../../models/Project.mjs' diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesRouter.mjs b/services/web/app/src/Features/LinkedFiles/LinkedFilesRouter.mjs index 735c3f1041..fa1a5ccb40 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesRouter.mjs +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesRouter.mjs @@ -1,6 +1,6 @@ import AuthorizationMiddleware from '../Authorization/AuthorizationMiddleware.mjs' import AuthenticationController from '../Authentication/AuthenticationController.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' import LinkedFilesController from './LinkedFilesController.mjs' diff --git a/services/web/app/src/Features/PasswordReset/PasswordResetController.mjs b/services/web/app/src/Features/PasswordReset/PasswordResetController.mjs index a4182e50d5..a945c93ffd 100644 --- a/services/web/app/src/Features/PasswordReset/PasswordResetController.mjs +++ b/services/web/app/src/Features/PasswordReset/PasswordResetController.mjs @@ -8,7 +8,7 @@ import UserSessionsManager from '../User/UserSessionsManager.mjs' import OError from '@overleaf/o-error' import EmailsHelper from '../Helpers/EmailHelper.mjs' import { expressify } from '@overleaf/promise-utils' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' const setNewUserPasswordSchema = z.object({ body: z.object({ diff --git a/services/web/app/src/Features/PasswordReset/PasswordResetRouter.mjs b/services/web/app/src/Features/PasswordReset/PasswordResetRouter.mjs index 5df869bc0b..cfd8e2f871 100644 --- a/services/web/app/src/Features/PasswordReset/PasswordResetRouter.mjs +++ b/services/web/app/src/Features/PasswordReset/PasswordResetRouter.mjs @@ -1,7 +1,7 @@ import PasswordResetController from './PasswordResetController.mjs' import AuthenticationController from '../Authentication/AuthenticationController.mjs' import CaptchaMiddleware from '../../Features/Captcha/CaptchaMiddleware.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' const rateLimiter = new RateLimiter('password_reset_rate_limit', { diff --git a/services/web/app/src/Features/Project/ProjectController.mjs b/services/web/app/src/Features/Project/ProjectController.mjs index 0effa757ed..6e7ec28b2b 100644 --- a/services/web/app/src/Features/Project/ProjectController.mjs +++ b/services/web/app/src/Features/Project/ProjectController.mjs @@ -44,8 +44,8 @@ import PublicAccessLevels from '../Authorization/PublicAccessLevels.mjs' import TagsHandler from '../Tags/TagsHandler.mjs' import TutorialHandler from '../Tutorial/TutorialHandler.mjs' import UserUpdater from '../User/UserUpdater.mjs' -import Modules from '../../infrastructure/Modules.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import Modules from '../../infrastructure/Modules.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' import UserGetter from '../User/UserGetter.mjs' import { isStandaloneAiAddOnPlanCode } from '../Subscription/AiHelper.mjs' import SubscriptionController from '../Subscription/SubscriptionController.mjs' diff --git a/services/web/app/src/Features/Project/ProjectDeleter.mjs b/services/web/app/src/Features/Project/ProjectDeleter.mjs index cf8f035516..eda7671270 100644 --- a/services/web/app/src/Features/Project/ProjectDeleter.mjs +++ b/services/web/app/src/Features/Project/ProjectDeleter.mjs @@ -3,8 +3,8 @@ import { db, ObjectId, READ_PREFERENCE_SECONDARY, -} from '../../infrastructure/mongodb.mjs' -import Modules from '../../infrastructure/Modules.mjs' +} from '../../infrastructure/mongodb.js' +import Modules from '../../infrastructure/Modules.js' import { callbackify } from 'node:util' import { Project } from '../../models/Project.mjs' import { DeletedProject } from '../../models/DeletedProject.mjs' diff --git a/services/web/app/src/Features/Project/ProjectDuplicator.mjs b/services/web/app/src/Features/Project/ProjectDuplicator.mjs index c189db966f..d125578651 100644 --- a/services/web/app/src/Features/Project/ProjectDuplicator.mjs +++ b/services/web/app/src/Features/Project/ProjectDuplicator.mjs @@ -20,7 +20,7 @@ import TpdsProjectFlusher from '../ThirdPartyDataStore/TpdsProjectFlusher.mjs' import _ from 'lodash' import TagsHandler from '../Tags/TagsHandler.mjs' import ClsiCacheManager from '../Compile/ClsiCacheManager.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' export default { duplicate: callbackify(duplicate), diff --git a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs index d526fa5202..59e0d72619 100644 --- a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs +++ b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs @@ -8,7 +8,7 @@ import OError from '@overleaf/o-error' import CooldownManager from '../Cooldown/CooldownManager.mjs' import Errors from '../Errors/Errors.js' import { Folder } from '../../models/Folder.mjs' -import LockManager from '../../infrastructure/LockManager.mjs' +import LockManager from '../../infrastructure/LockManager.js' import { Project } from '../../models/Project.mjs' import ProjectEntityHandler from './ProjectEntityHandler.mjs' import ProjectGetter from './ProjectGetter.mjs' diff --git a/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.mjs b/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.mjs index 9d243a555c..34d76d893c 100644 --- a/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.mjs +++ b/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.mjs @@ -9,7 +9,7 @@ import DocstoreManager from '../Docstore/DocstoreManager.mjs' import DocumentUpdaterHandler from '../../Features/DocumentUpdater/DocumentUpdaterHandler.mjs' import Errors from '../Errors/Errors.js' import FileStoreHandler from '../FileStore/FileStoreHandler.mjs' -import LockManager from '../../infrastructure/LockManager.mjs' +import LockManager from '../../infrastructure/LockManager.js' import { Project } from '../../models/Project.mjs' import ProjectEntityHandler from './ProjectEntityHandler.mjs' import ProjectGetter from './ProjectGetter.mjs' @@ -19,7 +19,7 @@ import ProjectUpdateHandler from './ProjectUpdateHandler.mjs' import ProjectEntityMongoUpdateHandler from './ProjectEntityMongoUpdateHandler.mjs' import SafePath from './SafePath.mjs' import TpdsUpdateSender from '../ThirdPartyDataStore/TpdsUpdateSender.mjs' -import FileWriter from '../../infrastructure/FileWriter.mjs' +import FileWriter from '../../infrastructure/FileWriter.js' import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs' import { callbackifyMultiResult, callbackify } from '@overleaf/promise-utils' import { iterablePaths } from './IterablePath.mjs' diff --git a/services/web/app/src/Features/Project/ProjectGetter.mjs b/services/web/app/src/Features/Project/ProjectGetter.mjs index a44e93645e..77069a7d72 100644 --- a/services/web/app/src/Features/Project/ProjectGetter.mjs +++ b/services/web/app/src/Features/Project/ProjectGetter.mjs @@ -1,8 +1,8 @@ -import { db } from '../../infrastructure/mongodb.mjs' +import { db } from '../../infrastructure/mongodb.js' import Mongo from '../Helpers/Mongo.mjs' import OError from '@overleaf/o-error' import { Project } from '../../models/Project.mjs' -import LockManager from '../../infrastructure/LockManager.mjs' +import LockManager from '../../infrastructure/LockManager.js' import { DeletedProject } from '../../models/DeletedProject.mjs' import { callbackifyAll } from '@overleaf/promise-utils' import ProjectEntityMongoUpdateHandler from './ProjectEntityMongoUpdateHandler.mjs' diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index c1f418406d..2acbb85c66 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -17,7 +17,7 @@ import logger from '@overleaf/logger' import Features from '../../infrastructure/Features.mjs' import SubscriptionViewModelBuilder from '../Subscription/SubscriptionViewModelBuilder.mjs' import NotificationsHandler from '../Notifications/NotificationsHandler.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { OError, V1ConnectionError } from '../Errors/Errors.js' import { User } from '../../models/User.mjs' import UserPrimaryEmailCheckHandler from '../User/UserPrimaryEmailCheckHandler.mjs' diff --git a/services/web/app/src/Features/Project/ProjectOptionsHandler.mjs b/services/web/app/src/Features/Project/ProjectOptionsHandler.mjs index b73cc8da42..d80e8c75c8 100644 --- a/services/web/app/src/Features/Project/ProjectOptionsHandler.mjs +++ b/services/web/app/src/Features/Project/ProjectOptionsHandler.mjs @@ -1,7 +1,7 @@ import { Project } from '../../models/Project.mjs' import settings from '@overleaf/settings' import { callbackify } from 'node:util' -import { db, ObjectId } from '../../infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../infrastructure/mongodb.js' import Errors from '../Errors/Errors.js' import mongodb from 'mongodb-legacy' const safeCompilers = ['xelatex', 'pdflatex', 'latex', 'lualatex'] diff --git a/services/web/app/src/Features/Project/ProjectRootDocManager.mjs b/services/web/app/src/Features/Project/ProjectRootDocManager.mjs index a640bf7927..3fff847fd1 100644 --- a/services/web/app/src/Features/Project/ProjectRootDocManager.mjs +++ b/services/web/app/src/Features/Project/ProjectRootDocManager.mjs @@ -23,7 +23,7 @@ import globby from 'globby' import _ from 'lodash' import { promisifyAll } from '@overleaf/promise-utils' import logger from '@overleaf/logger' -import { BackgroundTaskTracker } from '../../infrastructure/GracefulShutdown.mjs' +import { BackgroundTaskTracker } from '../../infrastructure/GracefulShutdown.js' const rootDocResets = new BackgroundTaskTracker('root doc resets') const ProjectRootDocManager = { diff --git a/services/web/app/src/Features/Security/LoginRateLimiter.mjs b/services/web/app/src/Features/Security/LoginRateLimiter.mjs index 505d6b3b6a..f85f9be5f7 100644 --- a/services/web/app/src/Features/Security/LoginRateLimiter.mjs +++ b/services/web/app/src/Features/Security/LoginRateLimiter.mjs @@ -1,4 +1,4 @@ -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import { callbackify } from '@overleaf/promise-utils' import Settings from '@overleaf/settings' diff --git a/services/web/app/src/Features/Security/OneTimeTokenHandler.mjs b/services/web/app/src/Features/Security/OneTimeTokenHandler.mjs index ba6b7147f6..2bfb7844e3 100644 --- a/services/web/app/src/Features/Security/OneTimeTokenHandler.mjs +++ b/services/web/app/src/Features/Security/OneTimeTokenHandler.mjs @@ -1,5 +1,5 @@ import crypto from 'node:crypto' -import { db } from '../../infrastructure/mongodb.mjs' +import { db } from '../../infrastructure/mongodb.js' import Errors from '../Errors/Errors.js' import { callbackify } from 'node:util' diff --git a/services/web/app/src/Features/ServerAdmin/AdminController.mjs b/services/web/app/src/Features/ServerAdmin/AdminController.mjs index c42520570d..0ab66029b1 100644 --- a/services/web/app/src/Features/ServerAdmin/AdminController.mjs +++ b/services/web/app/src/Features/ServerAdmin/AdminController.mjs @@ -6,7 +6,7 @@ import TpdsUpdateSender from '../ThirdPartyDataStore/TpdsUpdateSender.mjs' import TpdsProjectFlusher from '../ThirdPartyDataStore/TpdsProjectFlusher.mjs' import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs' import SystemMessageManager from '../SystemMessages/SystemMessageManager.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' const AdminController = { _sendDisconnectAllUsersMessage: delay => { diff --git a/services/web/app/src/Features/Spelling/LearnedWordsManager.mjs b/services/web/app/src/Features/Spelling/LearnedWordsManager.mjs index dc2d78fcb0..aae59aa51b 100644 --- a/services/web/app/src/Features/Spelling/LearnedWordsManager.mjs +++ b/services/web/app/src/Features/Spelling/LearnedWordsManager.mjs @@ -1,4 +1,4 @@ -import mongodb from '../../infrastructure/mongodb.mjs' +import mongodb from '../../infrastructure/mongodb.js' import { callbackify } from 'node:util' import Settings from '@overleaf/settings' import Errors from '../Errors/Errors.js' diff --git a/services/web/app/src/Features/Spelling/SpellingController.mjs b/services/web/app/src/Features/Spelling/SpellingController.mjs index 2e55ad5691..1447de1e92 100644 --- a/services/web/app/src/Features/Spelling/SpellingController.mjs +++ b/services/web/app/src/Features/Spelling/SpellingController.mjs @@ -2,7 +2,7 @@ import SessionManager from '../Authentication/SessionManager.mjs' import LearnedWordsManager from './LearnedWordsManager.mjs' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' const learnSchema = z.object({ body: z.object({ diff --git a/services/web/app/src/Features/Subscription/FeaturesUpdater.mjs b/services/web/app/src/Features/Subscription/FeaturesUpdater.mjs index 13a5ae9b61..c4bd3d7ee6 100644 --- a/services/web/app/src/Features/Subscription/FeaturesUpdater.mjs +++ b/services/web/app/src/Features/Subscription/FeaturesUpdater.mjs @@ -14,7 +14,7 @@ import InstitutionsFeatures from '../Institutions/InstitutionsFeatures.mjs' import UserGetter from '../User/UserGetter.mjs' import AnalyticsManager from '../Analytics/AnalyticsManager.mjs' import Queues from '../../infrastructure/Queues.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import { AI_ADD_ON_CODE } from './AiHelper.mjs' // import { fetchNothing } from '@overleaf/fetch-utils' import metrics from '@overleaf/metrics' diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.mjs b/services/web/app/src/Features/Subscription/SubscriptionController.mjs index 7e29d607c0..e85c7fd351 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionController.mjs @@ -19,7 +19,7 @@ import OError from '@overleaf/o-error' import Errors from './Errors.mjs' import SplitTestHandler from '../SplitTests/SplitTestHandler.mjs' import AuthorizationManager from '../Authorization/AuthorizationManager.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import async from 'async' import HttpErrorHandler from '../Errors/HttpErrorHandler.mjs' import RecurlyClient from './RecurlyClient.mjs' @@ -32,7 +32,7 @@ import { User } from '../../models/User.mjs' import UserGetter from '../User/UserGetter.mjs' import PermissionsManager from '../Authorization/PermissionsManager.mjs' import { sanitizeSessionUserForFrontEnd } from '../../infrastructure/FrontEndUser.mjs' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' import { IndeterminateInvoiceError } from '../Errors/Errors.js' import SubscriptionLocator from './SubscriptionLocator.mjs' diff --git a/services/web/app/src/Features/Subscription/SubscriptionGroupController.mjs b/services/web/app/src/Features/Subscription/SubscriptionGroupController.mjs index 208c12f72f..746274c161 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionGroupController.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionGroupController.mjs @@ -6,10 +6,10 @@ import SubscriptionLocator from './SubscriptionLocator.mjs' import SessionManager from '../Authentication/SessionManager.mjs' import UserAuditLogHandler from '../User/UserAuditLogHandler.mjs' import { expressify } from '@overleaf/promise-utils' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import UserGetter from '../User/UserGetter.mjs' import { Subscription } from '../../models/Subscription.mjs' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' import { isProfessionalGroupPlan } from './PlansHelper.mjs' import { MissingBillingInfoError, diff --git a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.mjs b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.mjs index ff584fee1c..facdf16a13 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.mjs @@ -10,7 +10,7 @@ import { User } from '../../models/User.mjs' import PlansLocator from './PlansLocator.mjs' import TeamInvitesHandler from './TeamInvitesHandler.mjs' import GroupPlansData from './GroupPlansData.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import PaymentProviderEntities from './PaymentProviderEntities.mjs' import { ManuallyCollectedError, diff --git a/services/web/app/src/Features/Subscription/SubscriptionHandler.mjs b/services/web/app/src/Features/Subscription/SubscriptionHandler.mjs index e6c55b70e9..edd5456230 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionHandler.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionHandler.mjs @@ -13,7 +13,7 @@ import EmailHandler from '../Email/EmailHandler.mjs' import { callbackify } from '@overleaf/promise-utils' import UserUpdater from '../User/UserUpdater.mjs' import { IndeterminateInvoiceError } from '../Errors/Errors.js' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' /** * @import { PaymentProviderSubscriptionChange } from './PaymentProviderEntities.mjs' diff --git a/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs b/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs index 9abbd823e0..36e2d201b9 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs @@ -3,7 +3,7 @@ import PermissionsController from '../Authorization/PermissionsController.mjs' import SubscriptionController from './SubscriptionController.mjs' import SubscriptionGroupController from './SubscriptionGroupController.mjs' import TeamInvitesController from './TeamInvitesController.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' import Settings from '@overleaf/settings' diff --git a/services/web/app/src/Features/Subscription/SubscriptionUpdater.mjs b/services/web/app/src/Features/Subscription/SubscriptionUpdater.mjs index a6ae37103b..f0a0ef7ec2 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionUpdater.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionUpdater.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../../infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../infrastructure/mongodb.js' import { callbackify } from '@overleaf/promise-utils' import { Subscription } from '../../models/Subscription.mjs' import SubscriptionLocator from './SubscriptionLocator.mjs' @@ -13,8 +13,8 @@ import UserAuditLogHandler from '../User/UserAuditLogHandler.mjs' import UserUpdater from '../User/UserUpdater.mjs' import AccountMappingHelper from '../Analytics/AccountMappingHelper.mjs' import { SSOConfig } from '../../models/SSOConfig.mjs' -import mongoose from '../../infrastructure/Mongoose.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import mongoose from '../../infrastructure/Mongoose.js' +import Modules from '../../infrastructure/Modules.js' /** * @typedef {import('../../../../types/subscription/dashboard/subscription').Subscription} Subscription diff --git a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.mjs b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.mjs index 422628f0eb..b573a4fad3 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.mjs @@ -17,7 +17,7 @@ import { callbackify } from '@overleaf/promise-utils' import { V1ConnectionError } from '../Errors/Errors.js' import FeaturesHelper from './FeaturesHelper.mjs' import { formatCurrency } from '../../util/currency.js' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import SplitTestHandler from '../SplitTests/SplitTestHandler.mjs' const { MEMBERS_LIMIT_ADD_ON_CODE } = PaymentProviderEntities diff --git a/services/web/app/src/Features/Subscription/TeamInvitesController.mjs b/services/web/app/src/Features/Subscription/TeamInvitesController.mjs index c4dee9970a..76f8a222dc 100644 --- a/services/web/app/src/Features/Subscription/TeamInvitesController.mjs +++ b/services/web/app/src/Features/Subscription/TeamInvitesController.mjs @@ -12,8 +12,8 @@ import { expressify } from '@overleaf/promise-utils' import HttpErrorHandler from '../Errors/HttpErrorHandler.mjs' import PermissionsManager from '../Authorization/PermissionsManager.mjs' import EmailHandler from '../Email/EmailHandler.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' +import Modules from '../../infrastructure/Modules.js' import UserAuditLogHandler from '../User/UserAuditLogHandler.mjs' import { sanitizeSessionUserForFrontEnd } from '../../infrastructure/FrontEndUser.mjs' diff --git a/services/web/app/src/Features/Subscription/TeamInvitesHandler.mjs b/services/web/app/src/Features/Subscription/TeamInvitesHandler.mjs index 073e1ca3c3..477127a0b1 100644 --- a/services/web/app/src/Features/Subscription/TeamInvitesHandler.mjs +++ b/services/web/app/src/Features/Subscription/TeamInvitesHandler.mjs @@ -1,7 +1,7 @@ import logger from '@overleaf/logger' import crypto from 'node:crypto' import settings from '@overleaf/settings' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import mongodb from 'mongodb-legacy' import { Subscription } from '../../models/Subscription.mjs' import { SSOConfig } from '../../models/SSOConfig.mjs' diff --git a/services/web/app/src/Features/SystemMessages/SystemMessageManager.mjs b/services/web/app/src/Features/SystemMessages/SystemMessageManager.mjs index 7561917ef0..a664a56fba 100644 --- a/services/web/app/src/Features/SystemMessages/SystemMessageManager.mjs +++ b/services/web/app/src/Features/SystemMessages/SystemMessageManager.mjs @@ -1,5 +1,5 @@ import { SystemMessage } from '../../models/SystemMessage.mjs' -import { addRequiredCleanupHandlerBeforeDrainingConnections } from '../../infrastructure/GracefulShutdown.mjs' +import { addRequiredCleanupHandlerBeforeDrainingConnections } from '../../infrastructure/GracefulShutdown.js' import { callbackifyAll } from '@overleaf/promise-utils' import logger from '@overleaf/logger' diff --git a/services/web/app/src/Features/Tags/TagsController.mjs b/services/web/app/src/Features/Tags/TagsController.mjs index 873f7ea0e5..c8ac8fca6f 100644 --- a/services/web/app/src/Features/Tags/TagsController.mjs +++ b/services/web/app/src/Features/Tags/TagsController.mjs @@ -1,7 +1,7 @@ import TagsHandler from './TagsHandler.mjs' import SessionManager from '../Authentication/SessionManager.mjs' import Errors from '../Errors/Errors.js' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' import { expressify } from '@overleaf/promise-utils' async function _getTags(userId, _req, res) { diff --git a/services/web/app/src/Features/Templates/TemplatesRouter.mjs b/services/web/app/src/Features/Templates/TemplatesRouter.mjs index 4579b04412..b44491dc00 100644 --- a/services/web/app/src/Features/Templates/TemplatesRouter.mjs +++ b/services/web/app/src/Features/Templates/TemplatesRouter.mjs @@ -1,7 +1,7 @@ import AuthenticationController from '../Authentication/AuthenticationController.mjs' import TemplatesController from './TemplatesController.mjs' import TemplatesMiddleware from './TemplatesMiddleware.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' import AnalyticsRegistrationSourceMiddleware from '../Analytics/AnalyticsRegistrationSourceMiddleware.mjs' diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs index 57e1a7e0fc..1149ba9939 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs @@ -10,7 +10,7 @@ import ProjectRootDocManager from '../Project/ProjectRootDocManager.mjs' import FileTypeManager from '../Uploads/FileTypeManager.mjs' import CooldownManager from '../Cooldown/CooldownManager.mjs' import Errors from '../Errors/Errors.js' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' async function newUpdate( userId, diff --git a/services/web/app/src/Features/Uploads/UploadsRouter.mjs b/services/web/app/src/Features/Uploads/UploadsRouter.mjs index d00c851dad..4cd3e90778 100644 --- a/services/web/app/src/Features/Uploads/UploadsRouter.mjs +++ b/services/web/app/src/Features/Uploads/UploadsRouter.mjs @@ -1,7 +1,7 @@ import AuthorizationMiddleware from '../Authorization/AuthorizationMiddleware.mjs' import AuthenticationController from '../Authentication/AuthenticationController.mjs' import ProjectUploadController from './ProjectUploadController.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' import Settings from '@overleaf/settings' diff --git a/services/web/app/src/Features/User/UserController.mjs b/services/web/app/src/Features/User/UserController.mjs index f9c1e6dad1..dbfa58d5a9 100644 --- a/services/web/app/src/Features/User/UserController.mjs +++ b/services/web/app/src/Features/User/UserController.mjs @@ -8,7 +8,7 @@ import metrics from '@overleaf/metrics' import AuthenticationManager from '../Authentication/AuthenticationManager.mjs' import SessionManager from '../Authentication/SessionManager.mjs' import Features from '../../infrastructure/Features.mjs' -import { z, validateReq } from '../../infrastructure/Validation.mjs' +import { z, validateReq } from '../../infrastructure/Validation.js' import UserAuditLogHandler from './UserAuditLogHandler.mjs' import UserSessionsManager from './UserSessionsManager.mjs' import UserUpdater from './UserUpdater.mjs' @@ -19,8 +19,8 @@ import EmailHandler from '../Email/EmailHandler.mjs' import UrlHelper from '../Helpers/UrlHelper.mjs' import { promisify } from 'node:util' import { expressify } from '@overleaf/promise-utils' -import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.js' +import Modules from '../../infrastructure/Modules.js' import OneTimeTokenHandler from '../Security/OneTimeTokenHandler.mjs' async function _sendSecurityAlertClearedSessions(user) { diff --git a/services/web/app/src/Features/User/UserDeleter.mjs b/services/web/app/src/Features/User/UserDeleter.mjs index 79eafa10df..ee220304b6 100644 --- a/services/web/app/src/Features/User/UserDeleter.mjs +++ b/services/web/app/src/Features/User/UserDeleter.mjs @@ -14,7 +14,7 @@ import UserMembershipsHandler from '../UserMembership/UserMembershipsHandler.mjs import UserSessionsManager from './UserSessionsManager.mjs' import UserAuditLogHandler from './UserAuditLogHandler.mjs' import InstitutionsAPI from '../Institutions/InstitutionsAPI.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import Errors from '../Errors/Errors.js' import OnboardingDataCollectionManager from '../OnboardingDataCollection/OnboardingDataCollectionManager.mjs' import EmailHandler from '../Email/EmailHandler.mjs' diff --git a/services/web/app/src/Features/User/UserEmailsController.mjs b/services/web/app/src/Features/User/UserEmailsController.mjs index cf9e8adf74..008bc62030 100644 --- a/services/web/app/src/Features/User/UserEmailsController.mjs +++ b/services/web/app/src/Features/User/UserEmailsController.mjs @@ -16,10 +16,10 @@ import AsyncFormHelper from '../Helpers/AsyncFormHelper.mjs' import AnalyticsManager from '../Analytics/AnalyticsManager.mjs' import UserPrimaryEmailCheckHandler from '../User/UserPrimaryEmailCheckHandler.mjs' import UserAuditLogHandler from './UserAuditLogHandler.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import Features from '../../infrastructure/Features.mjs' import tsscmp from 'tsscmp' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' const AUDIT_LOG_TOKEN_PREFIX_LENGTH = 10 diff --git a/services/web/app/src/Features/User/UserGetter.mjs b/services/web/app/src/Features/User/UserGetter.mjs index 71b7312746..c2459c35dc 100644 --- a/services/web/app/src/Features/User/UserGetter.mjs +++ b/services/web/app/src/Features/User/UserGetter.mjs @@ -1,5 +1,5 @@ import { callbackify } from 'node:util' -import { db } from '../../infrastructure/mongodb.mjs' +import { db } from '../../infrastructure/mongodb.js' import moment from 'moment' import settings from '@overleaf/settings' import InstitutionsAPI from '../Institutions/InstitutionsAPI.mjs' @@ -8,9 +8,9 @@ import Errors from '../Errors/Errors.js' import Features from '../../infrastructure/Features.mjs' import { User } from '../../models/User.mjs' import Mongo from '../Helpers/Mongo.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import FeaturesHelper from '../Subscription/FeaturesHelper.mjs' -import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.mjs' +import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.js' const { normalizeQuery, normalizeMultiQuery } = Mongo const InstitutionsAPIPromises = InstitutionsAPI.promises diff --git a/services/web/app/src/Features/User/UserHandler.mjs b/services/web/app/src/Features/User/UserHandler.mjs index e9da67f7b9..1a670dbc83 100644 --- a/services/web/app/src/Features/User/UserHandler.mjs +++ b/services/web/app/src/Features/User/UserHandler.mjs @@ -1,6 +1,6 @@ import { callbackify } from 'node:util' import TeamInvitesHandler from '../Subscription/TeamInvitesHandler.mjs' -import { db, READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.mjs' +import { db, READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.js' async function populateTeamInvites(user) { return await TeamInvitesHandler.promises.createTeamInvitesForLegacyInvitedEmail( diff --git a/services/web/app/src/Features/User/UserPagesController.mjs b/services/web/app/src/Features/User/UserPagesController.mjs index b4c72fd82f..42d7167b9d 100644 --- a/services/web/app/src/Features/User/UserPagesController.mjs +++ b/services/web/app/src/Features/User/UserPagesController.mjs @@ -10,7 +10,7 @@ import SubscriptionLocator from '../Subscription/SubscriptionLocator.mjs' import _ from 'lodash' import { expressify } from '@overleaf/promise-utils' import Features from '../../infrastructure/Features.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' async function settingsPage(req, res) { const userId = SessionManager.getLoggedInUserId(req.session) diff --git a/services/web/app/src/Features/User/UserSessionsRedis.mjs b/services/web/app/src/Features/User/UserSessionsRedis.mjs index 2e7fe27283..ff41eb6b15 100644 --- a/services/web/app/src/Features/User/UserSessionsRedis.mjs +++ b/services/web/app/src/Features/User/UserSessionsRedis.mjs @@ -1,4 +1,4 @@ -import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../infrastructure/RedisWrapper.js' const rclient = RedisWrapper.client('websessions') const UserSessionsRedis = { diff --git a/services/web/app/src/Features/User/UserUpdater.mjs b/services/web/app/src/Features/User/UserUpdater.mjs index d27aff6ffe..4f4cdf2ba7 100644 --- a/services/web/app/src/Features/User/UserUpdater.mjs +++ b/services/web/app/src/Features/User/UserUpdater.mjs @@ -1,6 +1,6 @@ import logger from '@overleaf/logger' import OError from '@overleaf/o-error' -import { db } from '../../infrastructure/mongodb.mjs' +import { db } from '../../infrastructure/mongodb.js' import Mongo from '../Helpers/Mongo.mjs' import { callbackify } from 'node:util' import UserGetter from './UserGetter.mjs' @@ -17,10 +17,10 @@ import EmailChangeHelper from '../Analytics/EmailChangeHelper.mjs' import SubscriptionLocator from '../Subscription/SubscriptionLocator.mjs' import NotificationsBuilder from '../Notifications/NotificationsBuilder.mjs' import _ from 'lodash' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import UserSessionsManager from './UserSessionsManager.mjs' import ThirdPartyIdentityManager from './ThirdPartyIdentityManager.mjs' -import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.mjs' +import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.js' const { normalizeQuery } = Mongo diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs index d0194dd0bb..381299d910 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs +++ b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs @@ -2,14 +2,14 @@ import SessionManager from '../Authentication/SessionManager.mjs' import UserMembershipHandler from './UserMembershipHandler.mjs' import Errors from '../Errors/Errors.js' import EmailHelper from '../Helpers/EmailHelper.mjs' -import { csvAttachment } from '../../infrastructure/Response.mjs' +import { csvAttachment } from '../../infrastructure/Response.js' import UserMembershipErrors from './UserMembershipErrors.mjs' import { SSOConfig } from '../../models/SSOConfig.mjs' import { Parser as CSVParser } from 'json2csv' import { expressify } from '@overleaf/promise-utils' import PlansLocator from '../Subscription/PlansLocator.mjs' import RecurlyClient from '../Subscription/RecurlyClient.mjs' -import Modules from '../../infrastructure/Modules.mjs' +import Modules from '../../infrastructure/Modules.js' import UserMembershipAuthorization from './UserMembershipAuthorization.mjs' async function manageGroupMembers(req, res, next) { diff --git a/services/web/app/src/Features/UserMembership/UserMembershipMiddleware.mjs b/services/web/app/src/Features/UserMembership/UserMembershipMiddleware.mjs index 13289c0096..1eac2e6c1d 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipMiddleware.mjs +++ b/services/web/app/src/Features/UserMembership/UserMembershipMiddleware.mjs @@ -10,7 +10,7 @@ import EntityConfigs from './UserMembershipEntityConfigs.mjs' import Errors from '../Errors/Errors.js' import HttpErrorHandler from '../Errors/HttpErrorHandler.mjs' import TemplatesManager from '../Templates/TemplatesManager.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.js' import AdminAuthorizationHelper from '../Helpers/AdminAuthorizationHelper.mjs' const { useAdminCapabilities } = AdminAuthorizationHelper diff --git a/services/web/app/src/Features/UserMembership/UserMembershipRouter.mjs b/services/web/app/src/Features/UserMembership/UserMembershipRouter.mjs index 36d02b4818..ecdd7571e5 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipRouter.mjs +++ b/services/web/app/src/Features/UserMembership/UserMembershipRouter.mjs @@ -2,7 +2,7 @@ import UserMembershipMiddleware from './UserMembershipMiddleware.mjs' import UserMembershipController from './UserMembershipController.mjs' import SubscriptionGroupController from '../Subscription/SubscriptionGroupController.mjs' import TeamInvitesController from '../Subscription/TeamInvitesController.mjs' -import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../infrastructure/RateLimiter.js' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' const rateLimiters = { diff --git a/services/web/app/src/infrastructure/AsyncLocalStorage.mjs b/services/web/app/src/infrastructure/AsyncLocalStorage.js similarity index 90% rename from services/web/app/src/infrastructure/AsyncLocalStorage.mjs rename to services/web/app/src/infrastructure/AsyncLocalStorage.js index eb822e6b9e..11461b57b1 100644 --- a/services/web/app/src/infrastructure/AsyncLocalStorage.mjs +++ b/services/web/app/src/infrastructure/AsyncLocalStorage.js @@ -1,5 +1,5 @@ // @ts-check -import { AsyncLocalStorage } from 'node:async_hooks' +const { AsyncLocalStorage } = require('node:async_hooks') /** * @typedef {Object} RequestContext @@ -31,7 +31,7 @@ function removeItem(key) { } } -export default { +module.exports = { middleware, storage: asyncLocalStorage, removeItem, diff --git a/services/web/app/src/infrastructure/ExpressLocals.mjs b/services/web/app/src/infrastructure/ExpressLocals.mjs index a49e218d91..b7c32faed4 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.mjs +++ b/services/web/app/src/infrastructure/ExpressLocals.mjs @@ -9,10 +9,10 @@ import contentDisposition from 'content-disposition' import Features from './Features.mjs' import SessionManager from '../Features/Authentication/SessionManager.mjs' import PackageVersions from './PackageVersions.js' -import Modules from './Modules.mjs' +import Modules from './Modules.js' import Errors from '../Features/Errors/Errors.js' import AdminAuthorizationHelper from '../Features/Helpers/AdminAuthorizationHelper.mjs' -import { addOptionalCleanupHandlerAfterDrainingConnections } from './GracefulShutdown.mjs' +import { addOptionalCleanupHandlerAfterDrainingConnections } from './GracefulShutdown.js' import { sanitizeSessionUserForFrontEnd } from './FrontEndUser.mjs' import { expressify } from '@overleaf/promise-utils' diff --git a/services/web/app/src/infrastructure/FileWriter.mjs b/services/web/app/src/infrastructure/FileWriter.js similarity index 88% rename from services/web/app/src/infrastructure/FileWriter.mjs rename to services/web/app/src/infrastructure/FileWriter.js index 12cf89fdd7..1a56f5fa26 100644 --- a/services/web/app/src/infrastructure/FileWriter.mjs +++ b/services/web/app/src/infrastructure/FileWriter.js @@ -5,19 +5,18 @@ * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -import fs from 'node:fs' +const fs = require('fs') +const OError = require('@overleaf/o-error') +const logger = require('@overleaf/logger') +const crypto = require('crypto') +const _ = require('lodash') +const Settings = require('@overleaf/settings') +const request = require('request') +const { Transform, pipeline } = require('stream') +const { FileTooLargeError } = require('../Features/Errors/Errors') +const { promisifyAll } = require('@overleaf/promise-utils') -import OError from '@overleaf/o-error' -import logger from '@overleaf/logger' -import crypto from 'node:crypto' -import _ from 'lodash' -import Settings from '@overleaf/settings' -import request from 'request' -import { Transform, pipeline } from 'node:stream' -import { FileTooLargeError } from '../Features/Errors/Errors.js' -import { promisifyAll } from '@overleaf/promise-utils' - -export class SizeLimitedStream extends Transform { +class SizeLimitedStream extends Transform { constructor(options) { options.autoDestroy = true super(options) @@ -180,8 +179,8 @@ const FileWriter = { }, } -FileWriter.promises = promisifyAll(FileWriter, { +module.exports = FileWriter +module.exports.promises = promisifyAll(FileWriter, { without: ['ensureDumpFolderExists'], }) - -export default FileWriter +module.exports.SizeLimitedStream = SizeLimitedStream diff --git a/services/web/app/src/infrastructure/GracefulShutdown.mjs b/services/web/app/src/infrastructure/GracefulShutdown.js similarity index 84% rename from services/web/app/src/infrastructure/GracefulShutdown.mjs rename to services/web/app/src/infrastructure/GracefulShutdown.js index c2fba67105..515f8b1e7e 100644 --- a/services/web/app/src/infrastructure/GracefulShutdown.mjs +++ b/services/web/app/src/infrastructure/GracefulShutdown.js @@ -9,37 +9,29 @@ - By now the node app should exit on its own. */ -import logger from '@overleaf/logger' - -import OError from '@overleaf/o-error' -import Settings from '@overleaf/settings' -import Metrics from '@overleaf/metrics' -import { setTimeout as sleep } from 'node:timers/promises' - +const logger = require('@overleaf/logger') +const OError = require('@overleaf/o-error') +const Settings = require('@overleaf/settings') +const Metrics = require('@overleaf/metrics') +const sleep = require('util').promisify(setTimeout) const optionalCleanupHandlersBeforeStoppingTraffic = [] const requiredCleanupHandlersBeforeDrainingConnections = [] const optionalCleanupHandlersAfterDrainingConnections = [] const connectionDrainer = [] -export function addConnectionDrainer(label, handler) { +function addConnectionDrainer(label, handler) { connectionDrainer.push({ label, handler }) } -export function addOptionalCleanupHandlerBeforeStoppingTraffic(label, handler) { +function addOptionalCleanupHandlerBeforeStoppingTraffic(label, handler) { optionalCleanupHandlersBeforeStoppingTraffic.push({ label, handler }) } -export function addRequiredCleanupHandlerBeforeDrainingConnections( - label, - handler -) { +function addRequiredCleanupHandlerBeforeDrainingConnections(label, handler) { requiredCleanupHandlersBeforeDrainingConnections.push({ label, handler }) } -export function addOptionalCleanupHandlerAfterDrainingConnections( - label, - handler -) { +function addOptionalCleanupHandlerAfterDrainingConnections(label, handler) { optionalCleanupHandlersAfterDrainingConnections.push({ label, handler }) } @@ -63,7 +55,7 @@ async function runHandlers(stage, handlers, logOnly) { * @param {import('net').Server} [server] * @param {number|string} [signal] */ -export async function gracefulShutdown(server, signal) { +async function gracefulShutdown(server, signal) { logger.warn({ signal }, 'graceful shutdown: started shutdown sequence') Settings.shuttingDown = true @@ -118,7 +110,7 @@ export async function gracefulShutdown(server, signal) { logger.info({}, 'graceful shutdown: ready to exit') } -export function triggerGracefulShutdown(server, signal) { +function triggerGracefulShutdown(server, signal) { gracefulShutdown(server, signal).catch(err => { logger.err( { err }, @@ -127,7 +119,7 @@ export function triggerGracefulShutdown(server, signal) { }) } -export class BackgroundTaskTracker { +class BackgroundTaskTracker { constructor(label) { // Do not leak any handles, just record the number of pending jobs. // In case we miss the cleanup of one job, the worst thing that can happen @@ -149,7 +141,7 @@ export class BackgroundTaskTracker { } } -export default { +module.exports = { BackgroundTaskTracker, addConnectionDrainer, addOptionalCleanupHandlerBeforeStoppingTraffic, diff --git a/services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs b/services/web/app/src/infrastructure/HttpPermissionsPolicy.js similarity index 95% rename from services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs rename to services/web/app/src/infrastructure/HttpPermissionsPolicy.js index 7491871da2..2c81ddb868 100644 --- a/services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs +++ b/services/web/app/src/infrastructure/HttpPermissionsPolicy.js @@ -1,6 +1,6 @@ // @ts-check -import Settings from '@overleaf/settings' +const Settings = require('@overleaf/settings') /** * @import { HttpPermissionsPolicy } from './types' @@ -85,4 +85,4 @@ class HttpPermissionsPolicyMiddleware { } } -export default HttpPermissionsPolicyMiddleware +module.exports = HttpPermissionsPolicyMiddleware diff --git a/services/web/app/src/infrastructure/LockManager.mjs b/services/web/app/src/infrastructure/LockManager.js similarity index 81% rename from services/web/app/src/infrastructure/LockManager.mjs rename to services/web/app/src/infrastructure/LockManager.js index 077ed66cab..8c21409a28 100644 --- a/services/web/app/src/infrastructure/LockManager.mjs +++ b/services/web/app/src/infrastructure/LockManager.js @@ -1,8 +1,9 @@ -import settings from '@overleaf/settings' -import RedisWrapper from './RedisWrapper.mjs' -import RedisWebLocker from '@overleaf/redis-wrapper/RedisWebLocker.js' +const settings = require('@overleaf/settings') +const RedisWrapper = require('./RedisWrapper') const rclient = RedisWrapper.client('lock') +const RedisWebLocker = require('@overleaf/redis-wrapper/RedisWebLocker') + // this method creates a lock manager with the provided timeout options function createLockManager(options) { return new RedisWebLocker({ @@ -32,4 +33,4 @@ LockManager.withTimeout = function (timeout) { return createLockManager(lockManagerSettingsWithTimeout) } -export default LockManager +module.exports = LockManager diff --git a/services/web/app/src/infrastructure/Metrics.mjs b/services/web/app/src/infrastructure/Metrics.js similarity index 60% rename from services/web/app/src/infrastructure/Metrics.mjs rename to services/web/app/src/infrastructure/Metrics.js index 31374badcc..b0fbf7aabd 100644 --- a/services/web/app/src/infrastructure/Metrics.mjs +++ b/services/web/app/src/infrastructure/Metrics.js @@ -1,28 +1,22 @@ // @ts-check -import Metrics from '@overleaf/metrics' +const Metrics = require('@overleaf/metrics') -const analyticsQueue = new Metrics.prom.Counter({ +exports.analyticsQueue = new Metrics.prom.Counter({ name: 'analytics_queue', help: 'Number of events sent to the analytics queue', labelNames: ['status', 'event_type'], }) -const revertFileDurationSeconds = new Metrics.prom.Histogram({ +exports.revertFileDurationSeconds = new Metrics.prom.Histogram({ name: 'timer_revert_file_duration_seconds', help: 'Duration of the file restore operation', buckets: [0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5], labelNames: ['type'], }) -const revertProjectDurationSeconds = new Metrics.prom.Histogram({ +exports.revertProjectDurationSeconds = new Metrics.prom.Histogram({ name: 'timer_revert_project_duration_seconds', help: 'Duration of the project restore operation', buckets: [0.5, 1, 2, 5, 10, 30, 60, 120, 300, 900, 1800], }) - -export default { - analyticsQueue, - revertFileDurationSeconds, - revertProjectDurationSeconds, -} diff --git a/services/web/app/src/infrastructure/Modules.mjs b/services/web/app/src/infrastructure/Modules.js similarity index 94% rename from services/web/app/src/infrastructure/Modules.mjs rename to services/web/app/src/infrastructure/Modules.js index 4d35491651..aea3aeb087 100644 --- a/services/web/app/src/infrastructure/Modules.mjs +++ b/services/web/app/src/infrastructure/Modules.js @@ -1,18 +1,17 @@ // @ts-check -import fs from 'node:fs' - -import Path from 'node:path' -import { promisify, callbackify } from 'node:util' -import Settings from '@overleaf/settings' -import Views from './Views.mjs' -import _ from 'lodash' -import Metrics from '@overleaf/metrics' +const fs = require('fs') +const Path = require('path') +const { promisify, callbackify } = require('util') +const Settings = require('@overleaf/settings') +const Views = require('./Views') +const _ = require('lodash') +const Metrics = require('@overleaf/metrics') /** @import { WebModule } from "../../../types/web-module" */ /** @import { RequestHandler } from "express" */ -const MODULE_BASE_PATH = Path.join(import.meta.dirname, '/../../../modules') +const MODULE_BASE_PATH = Path.join(__dirname, '/../../../modules') /** @type {WebModule[]} */ const _modules = [] @@ -208,7 +207,7 @@ async function getMiddleware(name) { return _middleware[name] || [] } -export default { +module.exports = { applyNonCsrfRouter, applyRouter, linkedFileAgentsIncludes, diff --git a/services/web/app/src/infrastructure/Mongoose.mjs b/services/web/app/src/infrastructure/Mongoose.js similarity index 81% rename from services/web/app/src/infrastructure/Mongoose.mjs rename to services/web/app/src/infrastructure/Mongoose.js index 0206ab8de7..a867757dc6 100644 --- a/services/web/app/src/infrastructure/Mongoose.mjs +++ b/services/web/app/src/infrastructure/Mongoose.js @@ -1,8 +1,8 @@ -import mongoose from 'mongoose' -import Settings from '@overleaf/settings' -import Metrics from '@overleaf/metrics' -import logger from '@overleaf/logger' -import { addConnectionDrainer } from './GracefulShutdown.mjs' +const mongoose = require('mongoose') +const Settings = require('@overleaf/settings') +const Metrics = require('@overleaf/metrics') +const logger = require('@overleaf/logger') +const { addConnectionDrainer } = require('./GracefulShutdown') mongoose.set('autoIndex', false) mongoose.set('strictQuery', false) @@ -54,4 +54,4 @@ mongoose.Promise = global.Promise mongoose.connectionPromise = connectionPromise -export default mongoose +module.exports = mongoose diff --git a/services/web/app/src/infrastructure/QueueWorkers.mjs b/services/web/app/src/infrastructure/QueueWorkers.mjs index 37614a02ed..77540e3d0f 100644 --- a/services/web/app/src/infrastructure/QueueWorkers.mjs +++ b/services/web/app/src/infrastructure/QueueWorkers.mjs @@ -7,12 +7,12 @@ import FeaturesUpdater from '../Features/Subscription/FeaturesUpdater.mjs' import { addOptionalCleanupHandlerBeforeStoppingTraffic, addRequiredCleanupHandlerBeforeDrainingConnections, -} from './GracefulShutdown.mjs' +} from './GracefulShutdown.js' import EmailHandler from '../Features/Email/EmailHandler.mjs' import logger from '@overleaf/logger' import OError from '@overleaf/o-error' -import Modules from './Modules.mjs' +import Modules from './Modules.js' /** * @typedef {{ diff --git a/services/web/app/src/infrastructure/Queues.mjs b/services/web/app/src/infrastructure/Queues.mjs index bea46766ca..74a44cfd2c 100644 --- a/services/web/app/src/infrastructure/Queues.mjs +++ b/services/web/app/src/infrastructure/Queues.mjs @@ -1,7 +1,7 @@ import Queue from 'bull' import Settings from '@overleaf/settings' import Features from '../infrastructure/Features.mjs' -import { addConnectionDrainer } from './GracefulShutdown.mjs' +import { addConnectionDrainer } from './GracefulShutdown.js' // Bull will keep a fixed number of the most recently completed jobs. This is // useful to inspect recently completed jobs. The bull prometheus exporter also diff --git a/services/web/app/src/infrastructure/RateLimiter.mjs b/services/web/app/src/infrastructure/RateLimiter.js similarity index 89% rename from services/web/app/src/infrastructure/RateLimiter.mjs rename to services/web/app/src/infrastructure/RateLimiter.js index 5dc7225371..6ce80b23a1 100644 --- a/services/web/app/src/infrastructure/RateLimiter.mjs +++ b/services/web/app/src/infrastructure/RateLimiter.js @@ -1,16 +1,16 @@ -import Settings from '@overleaf/settings' -import Metrics from '@overleaf/metrics' -import logger from '@overleaf/logger' -import RedisWrapper from './RedisWrapper.mjs' -import RateLimiterFlexible from 'rate-limiter-flexible' -import OError from '@overleaf/o-error' +const Settings = require('@overleaf/settings') +const Metrics = require('@overleaf/metrics') +const logger = require('@overleaf/logger') +const RedisWrapper = require('./RedisWrapper') +const RateLimiterFlexible = require('rate-limiter-flexible') +const OError = require('@overleaf/o-error') const rclient = RedisWrapper.client('ratelimiter') /** * Wrapper over the RateLimiterRedis class */ -export class RateLimiter { +class RateLimiter { #opts /** @@ -122,13 +122,13 @@ export class RateLimiter { * Shared rate limiters */ -export const openProjectRateLimiter = new RateLimiter('open-project', { +const openProjectRateLimiter = new RateLimiter('open-project', { points: 15, duration: 60, }) // Keep in sync with the can-skip-captcha options. -export const overleafLoginRateLimiter = new RateLimiter( +const overleafLoginRateLimiter = new RateLimiter( 'overleaf-login', Settings.rateLimit?.login?.ip || { points: 20, @@ -137,7 +137,7 @@ export const overleafLoginRateLimiter = new RateLimiter( } ) -export default { +module.exports = { RateLimiter, openProjectRateLimiter, overleafLoginRateLimiter, diff --git a/services/web/app/src/infrastructure/RedisWrapper.mjs b/services/web/app/src/infrastructure/RedisWrapper.js similarity index 76% rename from services/web/app/src/infrastructure/RedisWrapper.mjs rename to services/web/app/src/infrastructure/RedisWrapper.js index 9acdd85529..4c27328e9b 100644 --- a/services/web/app/src/infrastructure/RedisWrapper.mjs +++ b/services/web/app/src/infrastructure/RedisWrapper.js @@ -1,6 +1,6 @@ -import Settings from '@overleaf/settings' -import redis from '@overleaf/redis-wrapper' -import { addConnectionDrainer } from './GracefulShutdown.mjs' +const Settings = require('@overleaf/settings') +const redis = require('@overleaf/redis-wrapper') +const { addConnectionDrainer } = require('./GracefulShutdown') /** * A per-feature interface to Redis, looks up the feature in `settings.redis` @@ -23,4 +23,4 @@ async function cleanupTestRedis() { await redis.cleanupTestRedis(rclient) } -export default { client, cleanupTestRedis } +module.exports = { client, cleanupTestRedis } diff --git a/services/web/app/src/infrastructure/RequestContentTypeDetection.js b/services/web/app/src/infrastructure/RequestContentTypeDetection.js new file mode 100644 index 0000000000..6c8c587de6 --- /dev/null +++ b/services/web/app/src/infrastructure/RequestContentTypeDetection.js @@ -0,0 +1,5 @@ +module.exports = { + acceptsJson(req) { + return req.accepts(['html', 'json']) === 'json' + }, +} diff --git a/services/web/app/src/infrastructure/RequestContentTypeDetection.mjs b/services/web/app/src/infrastructure/RequestContentTypeDetection.mjs deleted file mode 100644 index 94046febaf..0000000000 --- a/services/web/app/src/infrastructure/RequestContentTypeDetection.mjs +++ /dev/null @@ -1,3 +0,0 @@ -export function acceptsJson(req) { - return req.accepts(['html', 'json']) === 'json' -} diff --git a/services/web/app/src/infrastructure/Response.mjs b/services/web/app/src/infrastructure/Response.js similarity index 76% rename from services/web/app/src/infrastructure/Response.mjs rename to services/web/app/src/infrastructure/Response.js index 75fb7fab2f..607dbaedc5 100644 --- a/services/web/app/src/infrastructure/Response.mjs +++ b/services/web/app/src/infrastructure/Response.js @@ -1,4 +1,4 @@ -export function csvAttachment(res, body, filename) { +function csvAttachment(res, body, filename) { if (!filename || !filename.endsWith('.csv')) { throw new Error('filename must end with .csv') } @@ -8,23 +8,23 @@ export function csvAttachment(res, body, filename) { res.send(body) } -export function preparePlainTextResponse(res) { +function preparePlainTextResponse(res) { res.setHeader('X-Content-Type-Options', 'nosniff') res.contentType('text/plain; charset=utf-8') } -export function plainTextResponse(res, body) { +function plainTextResponse(res, body) { preparePlainTextResponse(res) res.send(body) } -export function xmlResponse(res, body) { +function xmlResponse(res, body) { res.setHeader('X-Content-Type-Options', 'nosniff') res.contentType('application/xml; charset=utf-8') res.send(body) } -export function prepareZipAttachment(res, filename) { +function prepareZipAttachment(res, filename) { if (!filename || !filename.endsWith('.zip')) { throw new Error('filename must end with .zip') } @@ -33,12 +33,12 @@ export function prepareZipAttachment(res, filename) { res.setHeader('X-Content-Type-Options', 'nosniff') } -export function zipAttachment(res, body, filename) { +function zipAttachment(res, body, filename) { prepareZipAttachment(res, filename) res.send(body) } -export default { +module.exports = { csvAttachment, plainTextResponse, preparePlainTextResponse, diff --git a/services/web/app/src/infrastructure/ServeStaticWrapper.mjs b/services/web/app/src/infrastructure/ServeStaticWrapper.mjs index 1462b0c327..fba667e25c 100644 --- a/services/web/app/src/infrastructure/ServeStaticWrapper.mjs +++ b/services/web/app/src/infrastructure/ServeStaticWrapper.mjs @@ -1,5 +1,5 @@ import express from 'express' -import { plainTextResponse } from './Response.mjs' +import { plainTextResponse } from './Response.js' /* This wrapper is implemented specifically to handle "Premature Close" errors. diff --git a/services/web/app/src/infrastructure/Server.mjs b/services/web/app/src/infrastructure/Server.mjs index d973452bd2..52044bf79a 100644 --- a/services/web/app/src/infrastructure/Server.mjs +++ b/services/web/app/src/infrastructure/Server.mjs @@ -7,7 +7,7 @@ import Router from '../router.mjs' import helmet from 'helmet' import UserSessionsRedis from '../Features/User/UserSessionsRedis.mjs' import Csrf from './Csrf.mjs' -import HttpPermissionsPolicyMiddleware from './HttpPermissionsPolicy.mjs' +import HttpPermissionsPolicyMiddleware from './HttpPermissionsPolicy.js' import SessionAutostartMiddleware from './SessionAutostartMiddleware.mjs' import AnalyticsManager from '../Features/Analytics/AnalyticsManager.mjs' import session from 'express-session' @@ -22,7 +22,7 @@ import { Strategy as LocalStrategy } from 'passport-local' import ReferalConnect from '../Features/Referal/ReferalConnect.mjs' import RedirectManager from './RedirectManager.mjs' import translations from './Translations.mjs' -import Views from './Views.mjs' +import Views from './Views.js' import Features from './Features.mjs' import ErrorController from '../Features/Errors/ErrorController.mjs' import HttpErrorHandler from '../Features/Errors/HttpErrorHandler.mjs' @@ -30,7 +30,7 @@ import UserSessionsManager from '../Features/User/UserSessionsManager.mjs' import AuthenticationController from '../Features/Authentication/AuthenticationController.mjs' import SessionManager from '../Features/Authentication/SessionManager.mjs' import AdminAuthorizationHelper from '../Features/Helpers/AdminAuthorizationHelper.mjs' -import Modules from './Modules.mjs' +import Modules from './Modules.js' import expressLocals from './ExpressLocals.mjs' import noCache from 'nocache' import os from 'node:os' @@ -141,7 +141,7 @@ if (Settings.enabledServices.includes('web')) { } if (Settings.precompilePugTemplatesAtBootTime) { logger.debug('precompiling views for web in production environment') - await Views.precompileViews(app) + Views.precompileViews(app) } Modules.loadViewIncludes(app) } diff --git a/services/web/app/src/infrastructure/SiteAdminHandler.mjs b/services/web/app/src/infrastructure/SiteAdminHandler.mjs index bcc120c66e..f9368f485f 100644 --- a/services/web/app/src/infrastructure/SiteAdminHandler.mjs +++ b/services/web/app/src/infrastructure/SiteAdminHandler.mjs @@ -5,7 +5,7 @@ import fs from 'node:fs' import { addOptionalCleanupHandlerAfterDrainingConnections, addRequiredCleanupHandlerBeforeDrainingConnections, -} from './GracefulShutdown.mjs' +} from './GracefulShutdown.js' import Features from './Features.mjs' import UserHandler from '../Features/User/UserHandler.mjs' diff --git a/services/web/app/src/infrastructure/Validation.js b/services/web/app/src/infrastructure/Validation.js new file mode 100644 index 0000000000..209f56a848 --- /dev/null +++ b/services/web/app/src/infrastructure/Validation.js @@ -0,0 +1,27 @@ +// @ts-check + +const { NotFoundError } = require('../Features/Errors/Errors') +const { + validateReq, + z, + zz, + ParamsError, +} = require('@overleaf/validation-tools') + +const validateReqWeb = (req, schema) => { + try { + return validateReq(req, schema) + } catch (err) { + if (err instanceof ParamsError) { + // convert into a NotFoundError that web understands + throw new NotFoundError('Not found').withCause(err) + } + throw err + } +} + +module.exports = { + validateReq: validateReqWeb, + z, + zz, +} diff --git a/services/web/app/src/infrastructure/Validation.mjs b/services/web/app/src/infrastructure/Validation.mjs deleted file mode 100644 index 930eb21aa3..0000000000 --- a/services/web/app/src/infrastructure/Validation.mjs +++ /dev/null @@ -1,30 +0,0 @@ -// @ts-check - -import { NotFoundError } from '../Features/Errors/Errors.js' - -import { - validateReq as validateReqBase, - z, - zz, - ParamsError, -} from '@overleaf/validation-tools' - -export { z, zz } from '@overleaf/validation-tools' - -export const validateReq = (req, schema) => { - try { - return validateReqBase(req, schema) - } catch (err) { - if (err instanceof ParamsError) { - // convert into a NotFoundError that web understands - throw new NotFoundError('Not found').withCause(err) - } - throw err - } -} - -export default { - validateReq, - z, - zz, -} diff --git a/services/web/app/src/infrastructure/Views.mjs b/services/web/app/src/infrastructure/Views.js similarity index 94% rename from services/web/app/src/infrastructure/Views.mjs rename to services/web/app/src/infrastructure/Views.js index b561f3550c..fc60eb8e81 100644 --- a/services/web/app/src/infrastructure/Views.mjs +++ b/services/web/app/src/infrastructure/Views.js @@ -1,9 +1,9 @@ -import logger from '@overleaf/logger' -import pug from 'pug' -import globby from 'globby' -import Settings from '@overleaf/settings' -import fs from 'node:fs' -import Path from 'node:path' +const logger = require('@overleaf/logger') +const pug = require('pug') +const globby = require('globby') +const Settings = require('@overleaf/settings') +const fs = require('fs') +const Path = require('path') // Generate list of view names from app/views function buildViewList() { @@ -147,7 +147,7 @@ function precompileViewsAndCacheToDisk() { ) } -export default { +module.exports = { // for tests PUG_COMPILE_ARGUMENTS, _expectMetaFor, @@ -169,7 +169,7 @@ export default { return viewIncludes }, - async precompileViews(app) { + precompileViews(app) { const startTime = Date.now() let success = 0 let precompiled = 0 @@ -179,7 +179,7 @@ export default { if (fs.existsSync(precompiledFilename)) { logger.debug({ filePath }, 'loading precompiled pug template') try { - pug.cache[filePath] = await import(precompiledFilename) + pug.cache[filePath] = require(precompiledFilename) precompiled++ continue } catch (err) { @@ -206,7 +206,7 @@ export default { }, } -if (import.meta.main) { +if (require.main === module) { precompileViewsAndCacheToDisk() process.exit(0) } diff --git a/services/web/app/src/infrastructure/mongodb.mjs b/services/web/app/src/infrastructure/mongodb.js similarity index 84% rename from services/web/app/src/infrastructure/mongodb.mjs rename to services/web/app/src/infrastructure/mongodb.js index 6ffc38639f..611463e8cc 100644 --- a/services/web/app/src/infrastructure/mongodb.mjs +++ b/services/web/app/src/infrastructure/mongodb.js @@ -1,9 +1,9 @@ -import mongodb from 'mongodb-legacy' -import OError from '@overleaf/o-error' -import Settings from '@overleaf/settings' -import MongoUtils from '@overleaf/mongo-utils' -import Mongoose from './Mongoose.mjs' -import { addConnectionDrainer } from './GracefulShutdown.mjs' +const mongodb = require('mongodb-legacy') +const OError = require('@overleaf/o-error') +const Settings = require('@overleaf/settings') +const MongoUtils = require('@overleaf/mongo-utils') +const Mongoose = require('./Mongoose') +const { addConnectionDrainer } = require('./GracefulShutdown') // Ensure Mongoose is using the same mongodb instance as the mongodb module, // otherwise we will get multiple versions of the ObjectId class. Mongoose @@ -15,11 +15,10 @@ if (Mongoose.mongo.ObjectId !== mongodb.ObjectId) { ) } -export const { ObjectId } = mongodb -const { ReadPreference } = mongodb +const { ObjectId, ReadPreference } = mongodb -export const READ_PREFERENCE_PRIMARY = ReadPreference.primary.mode -export const READ_PREFERENCE_SECONDARY = Settings.mongo.hasSecondaries +const READ_PREFERENCE_PRIMARY = ReadPreference.primary.mode +const READ_PREFERENCE_SECONDARY = Settings.mongo.hasSecondaries ? ReadPreference.secondary.mode : ReadPreference.secondaryPreferred.mode @@ -33,7 +32,7 @@ addConnectionDrainer('mongodb', async () => { }) const internalDb = mongoClient.db() -export const db = { +const db = { contacts: internalDb.collection('contacts'), deletedProjects: internalDb.collection('deletedProjects'), deletedSubscriptions: internalDb.collection('deletedSubscriptions'), @@ -86,36 +85,36 @@ export const db = { scriptLogs: internalDb.collection('scriptLogs'), } -export const connectionPromise = mongoClient.connect() +const connectionPromise = mongoClient.connect() -export async function getCollectionNames() { +async function getCollectionNames() { const internalDb = mongoClient.db() const collections = await internalDb.collections() return collections.map(collection => collection.collectionName) } -export async function cleanupTestDatabase() { +async function cleanupTestDatabase() { await MongoUtils.cleanupTestDatabase(mongoClient) } -export async function dropTestDatabase() { +async function dropTestDatabase() { await MongoUtils.dropTestDatabase(mongoClient) } /** * WARNING: Consider using a pre-populated collection from `db` to avoid typos! */ -export async function getCollectionInternal(name) { +async function getCollectionInternal(name) { const internalDb = mongoClient.db() return internalDb.collection(name) } -export async function waitForDb() { +async function waitForDb() { await connectionPromise } -export default { +module.exports = { db, ObjectId, connectionPromise, diff --git a/services/web/app/src/models/DeletedProject.mjs b/services/web/app/src/models/DeletedProject.mjs index 9cfeca0ab2..652c052849 100644 --- a/services/web/app/src/models/DeletedProject.mjs +++ b/services/web/app/src/models/DeletedProject.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import { ProjectSchema } from './Project.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/DeletedSubscription.mjs b/services/web/app/src/models/DeletedSubscription.mjs index a960ae1fe8..b37d2f1ea6 100644 --- a/services/web/app/src/models/DeletedSubscription.mjs +++ b/services/web/app/src/models/DeletedSubscription.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import { SubscriptionSchema } from './Subscription.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/DeletedUser.mjs b/services/web/app/src/models/DeletedUser.mjs index e8c8e84a9b..17f221c3ce 100644 --- a/services/web/app/src/models/DeletedUser.mjs +++ b/services/web/app/src/models/DeletedUser.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import { UserSchema } from './User.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Doc.mjs b/services/web/app/src/models/Doc.mjs index 298dee2fa7..c06ff3b775 100644 --- a/services/web/app/src/models/Doc.mjs +++ b/services/web/app/src/models/Doc.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/DocSnapshot.mjs b/services/web/app/src/models/DocSnapshot.mjs index fe137a2197..0a5793f818 100644 --- a/services/web/app/src/models/DocSnapshot.mjs +++ b/services/web/app/src/models/DocSnapshot.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/Feedback.mjs b/services/web/app/src/models/Feedback.mjs index be4e9bf7f2..ef583a0ac9 100644 --- a/services/web/app/src/models/Feedback.mjs +++ b/services/web/app/src/models/Feedback.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/File.mjs b/services/web/app/src/models/File.mjs index 15553ed2b0..60742e6797 100644 --- a/services/web/app/src/models/File.mjs +++ b/services/web/app/src/models/File.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/Folder.mjs b/services/web/app/src/models/Folder.mjs index a4ba334962..7ac893f868 100644 --- a/services/web/app/src/models/Folder.mjs +++ b/services/web/app/src/models/Folder.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import { DocSchema } from './Doc.mjs' import { FileSchema } from './File.mjs' diff --git a/services/web/app/src/models/GlobalMetric.mjs b/services/web/app/src/models/GlobalMetric.mjs index 6d0884cf41..de019d40b2 100644 --- a/services/web/app/src/models/GlobalMetric.mjs +++ b/services/web/app/src/models/GlobalMetric.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const GlobalMetricSchema = new Schema( diff --git a/services/web/app/src/models/GroupAuditLogEntry.mjs b/services/web/app/src/models/GroupAuditLogEntry.mjs index 6598c92d4e..5d834df350 100644 --- a/services/web/app/src/models/GroupAuditLogEntry.mjs +++ b/services/web/app/src/models/GroupAuditLogEntry.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const GroupAuditLogEntrySchema = new Schema( diff --git a/services/web/app/src/models/GroupPolicy.mjs b/services/web/app/src/models/GroupPolicy.mjs index 4e87d1fbb1..c38488aa63 100644 --- a/services/web/app/src/models/GroupPolicy.mjs +++ b/services/web/app/src/models/GroupPolicy.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/Institution.mjs b/services/web/app/src/models/Institution.mjs index bccf80ddd0..a51dbd3f0b 100644 --- a/services/web/app/src/models/Institution.mjs +++ b/services/web/app/src/models/Institution.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import settings from '@overleaf/settings' import logger from '@overleaf/logger' import { promisify } from '@overleaf/promise-utils' diff --git a/services/web/app/src/models/OauthAccessToken.mjs b/services/web/app/src/models/OauthAccessToken.mjs index 3cc2a22058..d3a9edc9fe 100644 --- a/services/web/app/src/models/OauthAccessToken.mjs +++ b/services/web/app/src/models/OauthAccessToken.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/OauthApplication.mjs b/services/web/app/src/models/OauthApplication.mjs index fe20908f53..83ff51fa55 100644 --- a/services/web/app/src/models/OauthApplication.mjs +++ b/services/web/app/src/models/OauthApplication.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/OauthAuthorizationCode.mjs b/services/web/app/src/models/OauthAuthorizationCode.mjs index 8d080ab026..9750750f1a 100644 --- a/services/web/app/src/models/OauthAuthorizationCode.mjs +++ b/services/web/app/src/models/OauthAuthorizationCode.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/OnboardingDataCollection.mjs b/services/web/app/src/models/OnboardingDataCollection.mjs index 11afc4c211..edab377914 100644 --- a/services/web/app/src/models/OnboardingDataCollection.mjs +++ b/services/web/app/src/models/OnboardingDataCollection.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const OnboardingDataCollectionSchema = new Schema( diff --git a/services/web/app/src/models/Project.mjs b/services/web/app/src/models/Project.mjs index e7a4b3968f..fec4769008 100644 --- a/services/web/app/src/models/Project.mjs +++ b/services/web/app/src/models/Project.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import _ from 'lodash' import { FolderSchema } from './Folder.mjs' import Errors from '../Features/Errors/Errors.js' diff --git a/services/web/app/src/models/ProjectAuditLogEntry.mjs b/services/web/app/src/models/ProjectAuditLogEntry.mjs index e955189200..7e668a60e3 100644 --- a/services/web/app/src/models/ProjectAuditLogEntry.mjs +++ b/services/web/app/src/models/ProjectAuditLogEntry.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const ProjectAuditLogEntrySchema = new Schema( diff --git a/services/web/app/src/models/ProjectHistoryFailure.mjs b/services/web/app/src/models/ProjectHistoryFailure.mjs index 7e40305989..f584945ce5 100644 --- a/services/web/app/src/models/ProjectHistoryFailure.mjs +++ b/services/web/app/src/models/ProjectHistoryFailure.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/ProjectInvite.mjs b/services/web/app/src/models/ProjectInvite.mjs index b269eab4cf..879cd9f49c 100644 --- a/services/web/app/src/models/ProjectInvite.mjs +++ b/services/web/app/src/models/ProjectInvite.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/Publisher.mjs b/services/web/app/src/models/Publisher.mjs index 10d34b2173..9bbbd24e54 100644 --- a/services/web/app/src/models/Publisher.mjs +++ b/services/web/app/src/models/Publisher.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import settings from '@overleaf/settings' import logger from '@overleaf/logger' import request from 'request' diff --git a/services/web/app/src/models/SSOConfig.mjs b/services/web/app/src/models/SSOConfig.mjs index 376409cd85..6db3584619 100644 --- a/services/web/app/src/models/SSOConfig.mjs +++ b/services/web/app/src/models/SSOConfig.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const SSOConfigSchema = new Schema( diff --git a/services/web/app/src/models/SamlCache.mjs b/services/web/app/src/models/SamlCache.mjs index 5233a47f5f..a58a76ea68 100644 --- a/services/web/app/src/models/SamlCache.mjs +++ b/services/web/app/src/models/SamlCache.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const SamlCacheSchema = new Schema( diff --git a/services/web/app/src/models/SamlLog.mjs b/services/web/app/src/models/SamlLog.mjs index a47e014401..929c7b2600 100644 --- a/services/web/app/src/models/SamlLog.mjs +++ b/services/web/app/src/models/SamlLog.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const SamlLogSchema = new Schema( diff --git a/services/web/app/src/models/ScriptLog.mjs b/services/web/app/src/models/ScriptLog.mjs index 7174e6da9e..9cc6b8655f 100644 --- a/services/web/app/src/models/ScriptLog.mjs +++ b/services/web/app/src/models/ScriptLog.mjs @@ -1,4 +1,4 @@ -import Mongoose from '../infrastructure/Mongoose.mjs' +import Mongoose from '../infrastructure/Mongoose.js' export const ScriptLogSchema = new Mongoose.Schema( { diff --git a/services/web/app/src/models/SplitTest.mjs b/services/web/app/src/models/SplitTest.mjs index dc6446e0c9..b15c81adb4 100644 --- a/services/web/app/src/models/SplitTest.mjs +++ b/services/web/app/src/models/SplitTest.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/Subscription.mjs b/services/web/app/src/models/Subscription.mjs index 74e6c1684d..416f637c6f 100644 --- a/services/web/app/src/models/Subscription.mjs +++ b/services/web/app/src/models/Subscription.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import { TeamInviteSchema } from './TeamInvite.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Survey.mjs b/services/web/app/src/models/Survey.mjs index 70b439a90d..3c98e19fb8 100644 --- a/services/web/app/src/models/Survey.mjs +++ b/services/web/app/src/models/Survey.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const MIN_NAME_LENGTH = 3 diff --git a/services/web/app/src/models/SystemMessage.mjs b/services/web/app/src/models/SystemMessage.mjs index 918e813fb6..4191801f4e 100644 --- a/services/web/app/src/models/SystemMessage.mjs +++ b/services/web/app/src/models/SystemMessage.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/Tag.mjs b/services/web/app/src/models/Tag.mjs index d92e9fb616..7824d95d53 100644 --- a/services/web/app/src/models/Tag.mjs +++ b/services/web/app/src/models/Tag.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const COLOR_REGEX = /^#[a-fA-F0-9]{6}$/ diff --git a/services/web/app/src/models/TeamInvite.mjs b/services/web/app/src/models/TeamInvite.mjs index e121f0606e..dfa31c09ff 100644 --- a/services/web/app/src/models/TeamInvite.mjs +++ b/services/web/app/src/models/TeamInvite.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose diff --git a/services/web/app/src/models/User.mjs b/services/web/app/src/models/User.mjs index 6b4a426430..5b401442b0 100644 --- a/services/web/app/src/models/User.mjs +++ b/services/web/app/src/models/User.mjs @@ -1,5 +1,5 @@ import Settings from '@overleaf/settings' -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' import TokenGenerator from '../Features/TokenGenerator/TokenGenerator.mjs' const { Schema } = mongoose const { ObjectId } = Schema diff --git a/services/web/app/src/models/UserAuditLogEntry.mjs b/services/web/app/src/models/UserAuditLogEntry.mjs index 353feb1ccf..11442a9d0c 100644 --- a/services/web/app/src/models/UserAuditLogEntry.mjs +++ b/services/web/app/src/models/UserAuditLogEntry.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose export const UserAuditLogEntrySchema = new Schema( diff --git a/services/web/app/src/models/UserFeatureUsage.mjs b/services/web/app/src/models/UserFeatureUsage.mjs index 1427715dfb..50c86127af 100644 --- a/services/web/app/src/models/UserFeatureUsage.mjs +++ b/services/web/app/src/models/UserFeatureUsage.mjs @@ -1,4 +1,4 @@ -import mongoose from '../infrastructure/Mongoose.mjs' +import mongoose from '../infrastructure/Mongoose.js' const { Schema } = mongoose const Usage = new Schema({ diff --git a/services/web/app/src/router.mjs b/services/web/app/src/router.mjs index 0b5e9c1fa5..1d50c2acdb 100644 --- a/services/web/app/src/router.mjs +++ b/services/web/app/src/router.mjs @@ -35,12 +35,12 @@ import ExportsController from './Features/Exports/ExportsController.mjs' import PasswordResetRouter from './Features/PasswordReset/PasswordResetRouter.mjs' import StaticPagesRouter from './Features/StaticPages/StaticPagesRouter.mjs' import ChatController from './Features/Chat/ChatController.mjs' -import Modules from './infrastructure/Modules.mjs' +import Modules from './infrastructure/Modules.js' import { RateLimiter, openProjectRateLimiter, overleafLoginRateLimiter, -} from './infrastructure/RateLimiter.mjs' +} from './infrastructure/RateLimiter.js' import RateLimiterMiddleware from './Features/Security/RateLimiterMiddleware.mjs' import InactiveProjectController from './Features/InactiveData/InactiveProjectController.mjs' import ContactRouter from './Features/Contacts/ContactRouter.mjs' @@ -61,10 +61,10 @@ import CaptchaMiddleware from './Features/Captcha/CaptchaMiddleware.mjs' import UnsupportedBrowserMiddleware from './infrastructure/UnsupportedBrowserMiddleware.mjs' import logger from '@overleaf/logger' import _ from 'lodash' -import { plainTextResponse } from './infrastructure/Response.mjs' +import { plainTextResponse } from './infrastructure/Response.js' import SocketDiagnostics from './Features/SocketDiagnostics/SocketDiagnostics.mjs' import ClsiCacheController from './Features/Compile/ClsiCacheController.mjs' -import AsyncLocalStorage from './infrastructure/AsyncLocalStorage.mjs' +import AsyncLocalStorage from './infrastructure/AsyncLocalStorage.js' const { renderUnsupportedBrowserPage, unsupportedBrowserMiddleware } = UnsupportedBrowserMiddleware diff --git a/services/web/bin/lint_flag_res_send_usage b/services/web/bin/lint_flag_res_send_usage index ea3ad30e23..99310716fc 100755 --- a/services/web/bin/lint_flag_res_send_usage +++ b/services/web/bin/lint_flag_res_send_usage @@ -14,7 +14,7 @@ POTENTIAL_SEND_USAGE=$(\ --regex "\.send\b" \ --regex "\bsend(" \ ) -HELPER_MODULE="app/src/infrastructure/Response.mjs" +HELPER_MODULE="app/src/infrastructure/Response.js" if [[ "$POTENTIAL_SEND_USAGE" == "$HELPER_MODULE" ]]; then exit 0 fi diff --git a/services/web/modules/history-v1/test/acceptance/src/HistoryTests.mjs b/services/web/modules/history-v1/test/acceptance/src/HistoryTests.mjs index 11fd0d337a..583f79aefb 100644 --- a/services/web/modules/history-v1/test/acceptance/src/HistoryTests.mjs +++ b/services/web/modules/history-v1/test/acceptance/src/HistoryTests.mjs @@ -1,7 +1,7 @@ import { expect } from 'chai' import _ from 'lodash' -import { db, ObjectId } from '../../../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../../../app/src/infrastructure/mongodb.js' import User from '../../../../../test/acceptance/src/helpers/User.mjs' import MockV1HistoryApiClass from '../../../../../test/acceptance/src/mocks/MockV1HistoryApi.mjs' diff --git a/services/web/modules/server-ce-scripts/scripts/change-compile-timeout.mjs b/services/web/modules/server-ce-scripts/scripts/change-compile-timeout.mjs index d66e2a88f0..07aeb7cf4d 100644 --- a/services/web/modules/server-ce-scripts/scripts/change-compile-timeout.mjs +++ b/services/web/modules/server-ce-scripts/scripts/change-compile-timeout.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' async function main() { const argv = minimist(process.argv.slice(2), { diff --git a/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs b/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs index 99a236c7e7..346257a2d2 100644 --- a/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs +++ b/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs @@ -2,7 +2,7 @@ import mongodb from 'mongodb-legacy' import { connectionPromise, db, -} from '../../../app/src/infrastructure/mongodb.mjs' +} from '../../../app/src/infrastructure/mongodb.js' const { ObjectId } = mongodb diff --git a/services/web/modules/server-ce-scripts/scripts/check-redis.mjs b/services/web/modules/server-ce-scripts/scripts/check-redis.mjs index 32f121ab2e..213bcc9714 100644 --- a/services/web/modules/server-ce-scripts/scripts/check-redis.mjs +++ b/services/web/modules/server-ce-scripts/scripts/check-redis.mjs @@ -1,4 +1,4 @@ -import RedisWrapper from '../../../app/src/infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../../app/src/infrastructure/RedisWrapper.js' const rclient = RedisWrapper.client('health_check') rclient.on('error', err => { console.error('Cannot connect to redis.') diff --git a/services/web/modules/server-ce-scripts/scripts/check-texlive-images.mjs b/services/web/modules/server-ce-scripts/scripts/check-texlive-images.mjs index 90a9137d7f..1675bbba04 100644 --- a/services/web/modules/server-ce-scripts/scripts/check-texlive-images.mjs +++ b/services/web/modules/server-ce-scripts/scripts/check-texlive-images.mjs @@ -1,4 +1,4 @@ -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' async function readImagesInUse() { const projectCount = await db.projects.countDocuments() diff --git a/services/web/modules/server-ce-scripts/scripts/create-user.mjs b/services/web/modules/server-ce-scripts/scripts/create-user.mjs index ae373c87b3..698631d204 100644 --- a/services/web/modules/server-ce-scripts/scripts/create-user.mjs +++ b/services/web/modules/server-ce-scripts/scripts/create-user.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import UserRegistrationHandler from '../../../app/src/Features/User/UserRegistrationHandler.mjs' import { fileURLToPath } from 'url' diff --git a/services/web/modules/server-ce-scripts/scripts/export-legacy-user-projects.mjs b/services/web/modules/server-ce-scripts/scripts/export-legacy-user-projects.mjs index 7b985a368a..1598309f71 100644 --- a/services/web/modules/server-ce-scripts/scripts/export-legacy-user-projects.mjs +++ b/services/web/modules/server-ce-scripts/scripts/export-legacy-user-projects.mjs @@ -6,14 +6,14 @@ import { existsSync, unlinkSync, renameSync, -} from 'node:fs' -import mongodb from '../../../app/src/infrastructure/mongodb.mjs' -import DocumentUpdaterHandler from '../../../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs' -import ProjectZipStreamManager from '../../../app/src/Features/Downloads/ProjectZipStreamManager.mjs' +} from 'fs' +import mongodb from '../../../app/src/infrastructure/mongodb.js' +import DocumentUpdaterHandler from '../../../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.js' +import ProjectZipStreamManager from '../../../app/src/Features/Downloads/ProjectZipStreamManager.js' import logger from 'logger-sharelatex' import { Project } from '../../../app/src/models/Project.mjs' import { User } from '../../../app/src/models/User.mjs' -import readline from 'node:readline' +import readline from 'readline' function parseArgs() { return minimist(process.argv.slice(2), { diff --git a/services/web/modules/server-ce-scripts/scripts/export-user-projects.mjs b/services/web/modules/server-ce-scripts/scripts/export-user-projects.mjs index 4dab9d62ab..f33edcddb8 100644 --- a/services/web/modules/server-ce-scripts/scripts/export-user-projects.mjs +++ b/services/web/modules/server-ce-scripts/scripts/export-user-projects.mjs @@ -11,7 +11,7 @@ import DocumentUpdaterHandler from '../../../app/src/Features/DocumentUpdater/Do import ProjectZipStreamManager from '../../../app/src/Features/Downloads/ProjectZipStreamManager.mjs' import logger from '@overleaf/logger' import { promisify } from '@overleaf/promise-utils' -import { gracefulShutdown } from '../../../app/src/infrastructure/GracefulShutdown.mjs' +import { gracefulShutdown } from '../../../app/src/infrastructure/GracefulShutdown.js' import { Project } from '../../../app/src/models/Project.mjs' import { User } from '../../../app/src/models/User.mjs' import readline from 'readline' diff --git a/services/web/modules/server-ce-scripts/scripts/rename-tag.mjs b/services/web/modules/server-ce-scripts/scripts/rename-tag.mjs index 66f396e717..32cbac793b 100644 --- a/services/web/modules/server-ce-scripts/scripts/rename-tag.mjs +++ b/services/web/modules/server-ce-scripts/scripts/rename-tag.mjs @@ -1,6 +1,6 @@ import minimist from 'minimist' +import { db } from '../../../app/src/infrastructure/mongodb.js' import { fileURLToPath } from 'url' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' const filename = fileURLToPath(import.meta.url) diff --git a/services/web/modules/server-ce-scripts/scripts/transfer-all-projects-to-user.mjs b/services/web/modules/server-ce-scripts/scripts/transfer-all-projects-to-user.mjs index 3037be47c6..6c54e9a3b2 100644 --- a/services/web/modules/server-ce-scripts/scripts/transfer-all-projects-to-user.mjs +++ b/services/web/modules/server-ce-scripts/scripts/transfer-all-projects-to-user.mjs @@ -1,4 +1,4 @@ -import { ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../../../app/src/infrastructure/mongodb.js' import minimist from 'minimist' import OwnershipTransferHandler from '../../../app/src/Features/Collaborators/OwnershipTransferHandler.mjs' import UserGetter from '../../../app/src/Features/User/UserGetter.mjs' diff --git a/services/web/modules/server-ce-scripts/scripts/upgrade-user-features.mjs b/services/web/modules/server-ce-scripts/scripts/upgrade-user-features.mjs index f397680f12..f70eebc71f 100644 --- a/services/web/modules/server-ce-scripts/scripts/upgrade-user-features.mjs +++ b/services/web/modules/server-ce-scripts/scripts/upgrade-user-features.mjs @@ -1,6 +1,6 @@ import Settings from '@overleaf/settings' import logger from '@overleaf/logger' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import FeaturesHelper from '../../../app/src/Features/Subscription/FeaturesHelper.mjs' import { fileURLToPath } from 'url' const DRY_RUN = !process.argv.includes('--dry-run=false') diff --git a/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.mjs b/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.mjs index 61343c03ec..2e38148fa5 100644 --- a/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.mjs +++ b/services/web/modules/server-ce-scripts/test/acceptance/src/ServerCEScriptsTests.mjs @@ -2,7 +2,7 @@ import { exec } from 'node:child_process' import fs from 'node:fs' import Settings from '@overleaf/settings' import { expect } from 'chai' -import { db } from '../../../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../../../app/src/infrastructure/mongodb.js' import UserHelper from '../../../../../test/acceptance/src/helpers/User.mjs' const { promises: User } = UserHelper diff --git a/services/web/package.json b/services/web/package.json index 4582c1eeeb..50d9874677 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -54,7 +54,7 @@ "routes": "bin/routes", "storybook": "storybook dev -p 6006 --no-open", "build-storybook": "storybook build", - "precompile-pug": "node app/src/infrastructure/Views.mjs", + "precompile-pug": "node app/src/infrastructure/Views", "local:nodemon": "set -a;. ../../config/dev-environment.env;. ./docker-compose.common.env;. ../../config/local-dev.env;. ./local-dev.env;. ../../config/local.env; set +a; echo $OVERLEAF_CONFIG; WEB_PORT=13000 LISTEN_ADDRESS=0.0.0.0 npm run nodemon", "local:webpack": "set -a;. ../../config/dev-environment.env;. ./docker-compose.common.env;. ../../config/local-dev.env;. ./local-dev.env;. ../../config/local.env; set +a; PORT=13808 OVERLEAF_CONFIG=$(pwd)/config/settings.webpack.js npm run webpack", "local:test:acceptance:run_dir": "set -a;. $(pwd)/docker-compose.common.env;. $(pwd)/local-test.env; set +a; npm run test:acceptance:run_dir", diff --git a/services/web/scripts/add_feature_override.mjs b/services/web/scripts/add_feature_override.mjs index 136ce2aa24..40a56bdf43 100644 --- a/services/web/scripts/add_feature_override.mjs +++ b/services/web/scripts/add_feature_override.mjs @@ -26,7 +26,7 @@ import minimist from 'minimist' import fs from 'node:fs' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import pLimit from 'p-limit' import FeaturesUpdater from '../app/src/Features/Subscription/FeaturesUpdater.mjs' import FeaturesHelper from '../app/src/Features/Subscription/FeaturesHelper.mjs' diff --git a/services/web/scripts/add_salesforce_data_to_subscriptions.mjs b/services/web/scripts/add_salesforce_data_to_subscriptions.mjs index e7fb4ee238..80cc4db36c 100755 --- a/services/web/scripts/add_salesforce_data_to_subscriptions.mjs +++ b/services/web/scripts/add_salesforce_data_to_subscriptions.mjs @@ -2,7 +2,7 @@ import fs from 'node:fs' import minimist from 'minimist' import { parse } from 'csv' import Stream from 'node:stream/promises' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { Subscription } from '../app/src/models/Subscription.mjs' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/add_user_count_to_csv.mjs b/services/web/scripts/add_user_count_to_csv.mjs index 294b4d93a8..2a404cd7cc 100644 --- a/services/web/scripts/add_user_count_to_csv.mjs +++ b/services/web/scripts/add_user_count_to_csv.mjs @@ -7,7 +7,7 @@ import fs from 'node:fs' import * as csv from 'csv/sync' import minimist from 'minimist' import UserGetter from '../app/src/Features/User/UserGetter.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import _ from 'lodash' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/analytics/backfill_recurly_to_subscription_mapping.mjs b/services/web/scripts/analytics/backfill_recurly_to_subscription_mapping.mjs index e6fe6b7958..6ac495325c 100644 --- a/services/web/scripts/analytics/backfill_recurly_to_subscription_mapping.mjs +++ b/services/web/scripts/analytics/backfill_recurly_to_subscription_mapping.mjs @@ -15,10 +15,10 @@ import logger from '@overleaf/logger' import minimist from 'minimist' import { z } from 'zod' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import AccountMappingHelper from '../../app/src/Features/Analytics/AccountMappingHelper.mjs' import { registerAccountMapping } from '../../app/src/Features/Analytics/AnalyticsManager.mjs' -import { triggerGracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.mjs' +import { triggerGracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' const paramsSchema = z.object({ diff --git a/services/web/scripts/analytics/backfill_stripe_to_subscription_mapping.mjs b/services/web/scripts/analytics/backfill_stripe_to_subscription_mapping.mjs index 572b426cb3..e0d89e0519 100644 --- a/services/web/scripts/analytics/backfill_stripe_to_subscription_mapping.mjs +++ b/services/web/scripts/analytics/backfill_stripe_to_subscription_mapping.mjs @@ -14,11 +14,11 @@ import logger from '@overleaf/logger' import minimist from 'minimist' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import AccountMappingHelper from '../../app/src/Features/Analytics/AccountMappingHelper.mjs' import { registerAccountMapping } from '../../app/src/Features/Analytics/AnalyticsManager.mjs' -import { gracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.mjs' -import Validation from '../../app/src/infrastructure/Validation.mjs' +import { gracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.js' +import Validation from '../../app/src/infrastructure/Validation.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' const paramsSchema = Validation.z.object({ diff --git a/services/web/scripts/attach_dangling_comments_to_doc.mjs b/services/web/scripts/attach_dangling_comments_to_doc.mjs index 32edb44659..9c929adeb8 100644 --- a/services/web/scripts/attach_dangling_comments_to_doc.mjs +++ b/services/web/scripts/attach_dangling_comments_to_doc.mjs @@ -6,7 +6,7 @@ import ChatApiHandler from '../app/src/Features/Chat/ChatApiHandler.mjs' import DocumentUpdaterHandler from '../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' import HistoryManager from '../app/src/Features/History/HistoryManager.mjs' -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' const OPTS = parseArgs() diff --git a/services/web/scripts/back_fill_staff_access.mjs b/services/web/scripts/back_fill_staff_access.mjs index eb3fcb97e8..10f1edfac9 100644 --- a/services/web/scripts/back_fill_staff_access.mjs +++ b/services/web/scripts/back_fill_staff_access.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import UserSessionsManager from '../app/src/Features/User/UserSessionsManager.mjs' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/back_fill_warning_user_personal_and_group_subscription.mjs b/services/web/scripts/back_fill_warning_user_personal_and_group_subscription.mjs index 08e8b0c84b..012c224685 100644 --- a/services/web/scripts/back_fill_warning_user_personal_and_group_subscription.mjs +++ b/services/web/scripts/back_fill_warning_user_personal_and_group_subscription.mjs @@ -1,5 +1,5 @@ import NotificationsBuilder from '../app/src/Features/Notifications/NotificationsBuilder.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/backfill_mixpanel_user_properties.mjs b/services/web/scripts/backfill_mixpanel_user_properties.mjs index 455b10a5c7..ab7259fb45 100644 --- a/services/web/scripts/backfill_mixpanel_user_properties.mjs +++ b/services/web/scripts/backfill_mixpanel_user_properties.mjs @@ -6,7 +6,7 @@ import Queues from '../app/src/infrastructure/Queues.mjs' import SubscriptionLocator from '../app/src/Features/Subscription/SubscriptionLocator.mjs' import PlansLocator from '../app/src/Features/Subscription/PlansLocator.mjs' import FeaturesHelper from '../app/src/Features/Subscription/FeaturesHelper.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const { getQueue } = Queues const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY || '10', 10) diff --git a/services/web/scripts/backfill_project_image_name.mjs b/services/web/scripts/backfill_project_image_name.mjs index 7c925a0131..97c60e2b58 100644 --- a/services/web/scripts/backfill_project_image_name.mjs +++ b/services/web/scripts/backfill_project_image_name.mjs @@ -1,7 +1,7 @@ // @ts-check import minimist from 'minimist' import { batchedUpdateWithResultHandling } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const argv = minimist(process.argv.slice(2)) const commit = argv.commit !== undefined diff --git a/services/web/scripts/backfill_user_properties.mjs b/services/web/scripts/backfill_user_properties.mjs index 70daa94486..9325170a51 100644 --- a/services/web/scripts/backfill_user_properties.mjs +++ b/services/web/scripts/backfill_user_properties.mjs @@ -4,7 +4,7 @@ import SubscriptionLocator from '../app/src/Features/Subscription/SubscriptionLo import PlansLocator from '../app/src/Features/Subscription/PlansLocator.mjs' import FeaturesHelper from '../app/src/Features/Subscription/FeaturesHelper.mjs' import AnalyticsManager from '../app/src/Features/Analytics/AnalyticsManager.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const WRITE_CONCURRENCY = parseInt(process.env.WRITE_CONCURRENCY, 10) || 10 diff --git a/services/web/scripts/check_docs.mjs b/services/web/scripts/check_docs.mjs index a7efb71307..654a79c002 100644 --- a/services/web/scripts/check_docs.mjs +++ b/services/web/scripts/check_docs.mjs @@ -6,7 +6,7 @@ import { db, ObjectId, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' import { NotFoundError } from '../app/src/Features/Errors/Errors.js' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/check_duplicate_collaborators.mjs b/services/web/scripts/check_duplicate_collaborators.mjs index 4655328dc2..cf4ba7eafd 100644 --- a/services/web/scripts/check_duplicate_collaborators.mjs +++ b/services/web/scripts/check_duplicate_collaborators.mjs @@ -16,7 +16,7 @@ import { batchedUpdate, READ_PREFERENCE_SECONDARY, } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import minimist from 'minimist' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/check_project_files.mjs b/services/web/scripts/check_project_files.mjs index aaf339c28e..dae68151b0 100644 --- a/services/web/scripts/check_project_files.mjs +++ b/services/web/scripts/check_project_files.mjs @@ -4,7 +4,7 @@ import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' import DocumentUpdaterHandler from '../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.mjs' import ProjectEntityMongoUpdateHandler from '../app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs' -import { waitForDb, db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { waitForDb, db, ObjectId } from '../app/src/infrastructure/mongodb.js' import HistoryManager from '../app/src/Features/History/HistoryManager.mjs' import logger from '@overleaf/logger' import minimist from 'minimist' diff --git a/services/web/scripts/clear_admin_sessions.mjs b/services/web/scripts/clear_admin_sessions.mjs index bbcce0fa0c..ae884e498d 100644 --- a/services/web/scripts/clear_admin_sessions.mjs +++ b/services/web/scripts/clear_admin_sessions.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import UserSessionsManager from '../app/src/Features/User/UserSessionsManager.mjs' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/clear_feedback_collection.mjs b/services/web/scripts/clear_feedback_collection.mjs index 694c30c7ec..60b44db556 100644 --- a/services/web/scripts/clear_feedback_collection.mjs +++ b/services/web/scripts/clear_feedback_collection.mjs @@ -5,7 +5,7 @@ * DRY_RUN=false node scripts/clear_feedback_collection.mjs 2022-11-01 # deletion mode */ -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import { fileURLToPath } from 'node:url' const runScript = async (timestamp, dryRun) => { diff --git a/services/web/scripts/clear_sessions_set_must_reconfirm.mjs b/services/web/scripts/clear_sessions_set_must_reconfirm.mjs index a306c7e431..3518ee9415 100644 --- a/services/web/scripts/clear_sessions_set_must_reconfirm.mjs +++ b/services/web/scripts/clear_sessions_set_must_reconfirm.mjs @@ -1,5 +1,5 @@ import fs from 'node:fs' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import UserUpdater from '../app/src/Features/User/UserUpdater.mjs' import UserSessionsManager from '../app/src/Features/User/UserSessionsManager.mjs' import UserAuditLogHandler from '../app/src/Features/User/UserAuditLogHandler.mjs' diff --git a/services/web/scripts/convert_doc_to_file.mjs b/services/web/scripts/convert_doc_to_file.mjs index 878c93bdc0..e8162d8045 100644 --- a/services/web/scripts/convert_doc_to_file.mjs +++ b/services/web/scripts/convert_doc_to_file.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import ProjectEntityUpdateHandler from '../app/src/Features/Project/ProjectEntityUpdateHandler.mjs' import Errors from '../app/src/Features/Errors/Errors.js' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/convert_track_changes_to_explicit_format.mjs b/services/web/scripts/convert_track_changes_to_explicit_format.mjs index ed812c7e89..1180589d1c 100644 --- a/services/web/scripts/convert_track_changes_to_explicit_format.mjs +++ b/services/web/scripts/convert_track_changes_to_explicit_format.mjs @@ -1,5 +1,5 @@ // @ts-check -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import { scriptRunner } from './lib/ScriptRunner.mjs' import CollaboratorsHandler from '../app/src/Features/Collaborators/CollaboratorsHandler.mjs' diff --git a/services/web/scripts/count_encrypted_access_tokens.mjs b/services/web/scripts/count_encrypted_access_tokens.mjs index b840a75ac1..e989d49d15 100644 --- a/services/web/scripts/count_encrypted_access_tokens.mjs +++ b/services/web/scripts/count_encrypted_access_tokens.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import _ from 'lodash' import { formatTokenUsageStats } from '@overleaf/access-token-encryptor/scripts/helpers/format-usage-stats.js' import { ensureMongoTimeout } from './helpers/env_variable_helper.mjs' diff --git a/services/web/scripts/count_image_files.mjs b/services/web/scripts/count_image_files.mjs index f5f00b8d41..33a9bcc1fd 100644 --- a/services/web/scripts/count_image_files.mjs +++ b/services/web/scripts/count_image_files.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import { extname } from 'node:path' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/count_project_size.mjs b/services/web/scripts/count_project_size.mjs index 0898c5df1f..31c83a69c0 100644 --- a/services/web/scripts/count_project_size.mjs +++ b/services/web/scripts/count_project_size.mjs @@ -1,5 +1,5 @@ import readline from 'node:readline' -import { ObjectId, db } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId, db } from '../app/src/infrastructure/mongodb.js' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.mjs' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.mjs' import Errors from '../app/src/Features/Errors/Errors.js' diff --git a/services/web/scripts/deactivate_projects.mjs b/services/web/scripts/deactivate_projects.mjs index 5389a63f92..cff78801e8 100755 --- a/services/web/scripts/deactivate_projects.mjs +++ b/services/web/scripts/deactivate_projects.mjs @@ -2,7 +2,7 @@ import minimist from 'minimist' import PQueue from 'p-queue' import InactiveProjectManager from '../app/src/Features/InactiveData/InactiveProjectManager.mjs' -import { gracefulShutdown } from '../app/src/infrastructure/GracefulShutdown.mjs' +import { gracefulShutdown } from '../app/src/infrastructure/GracefulShutdown.js' import logger from '@overleaf/logger' // Global variables for tracking job and error counts diff --git a/services/web/scripts/delete-duplicate-splittest-versions/delete_test_dupes.mjs b/services/web/scripts/delete-duplicate-splittest-versions/delete_test_dupes.mjs index 3ad6f9ce16..9daabc78e6 100644 --- a/services/web/scripts/delete-duplicate-splittest-versions/delete_test_dupes.mjs +++ b/services/web/scripts/delete-duplicate-splittest-versions/delete_test_dupes.mjs @@ -1,4 +1,4 @@ -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import minimist from 'minimist' const argv = minimist(process.argv.slice(2)) diff --git a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs index 82405e96fa..4f400ebf9b 100644 --- a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs +++ b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs @@ -1,7 +1,7 @@ import fs from 'node:fs' import minimist from 'minimist' import readline from 'node:readline' -import { db, ObjectId } from '../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../app/src/infrastructure/mongodb.js' import DocstoreManagerModule from '../../app/src/Features/Docstore/DocstoreManager.mjs' const { promises: DocstoreManager } = DocstoreManagerModule diff --git a/services/web/scripts/delete_dangling_comments.mjs b/services/web/scripts/delete_dangling_comments.mjs index 7fcc56a6d2..8e0cdd5ca3 100644 --- a/services/web/scripts/delete_dangling_comments.mjs +++ b/services/web/scripts/delete_dangling_comments.mjs @@ -5,7 +5,7 @@ import ChatApiHandler from '../app/src/Features/Chat/ChatApiHandler.mjs' import DocumentUpdaterHandler from '../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' import HistoryManager from '../app/src/Features/History/HistoryManager.mjs' -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' const OPTS = parseArgs() diff --git a/services/web/scripts/delete_dangling_file_refs.mjs b/services/web/scripts/delete_dangling_file_refs.mjs index db72473a6f..2a290b162c 100644 --- a/services/web/scripts/delete_dangling_file_refs.mjs +++ b/services/web/scripts/delete_dangling_file_refs.mjs @@ -5,7 +5,7 @@ import minimist from 'minimist' import mongodb from 'mongodb-legacy' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import Errors from '../app/src/Features/Errors/Errors.js' import ProjectEntityMongoUpdateHandler from '../app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs' import { iterablePaths } from '../app/src/Features/Project/IterablePath.mjs' diff --git a/services/web/scripts/delete_old_writefull_refresh_tokens.mjs b/services/web/scripts/delete_old_writefull_refresh_tokens.mjs index ced073617c..cb275d4423 100644 --- a/services/web/scripts/delete_old_writefull_refresh_tokens.mjs +++ b/services/web/scripts/delete_old_writefull_refresh_tokens.mjs @@ -1,6 +1,6 @@ import minimist from 'minimist' import { scriptRunner } from './lib/ScriptRunner.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const argv = minimist(process.argv.slice(2)) diff --git a/services/web/scripts/delete_orphaned_chat_threads.mjs b/services/web/scripts/delete_orphaned_chat_threads.mjs index e8878d8028..c9a3c59876 100644 --- a/services/web/scripts/delete_orphaned_chat_threads.mjs +++ b/services/web/scripts/delete_orphaned_chat_threads.mjs @@ -4,7 +4,7 @@ import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import ChatApiHandler from '../app/src/Features/Chat/ChatApiHandler.mjs' import DeleteOrphanedDataHelper from './delete_orphaned_data_helper.mjs' import { ensureMongoTimeout } from './helpers/env_variable_helper.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const { ObjectId } = mongodb const { getHardDeletedProjectIds } = DeleteOrphanedDataHelper diff --git a/services/web/scripts/delete_orphaned_data_helper.mjs b/services/web/scripts/delete_orphaned_data_helper.mjs index ef4c66a1b8..c4468390ec 100644 --- a/services/web/scripts/delete_orphaned_data_helper.mjs +++ b/services/web/scripts/delete_orphaned_data_helper.mjs @@ -2,7 +2,7 @@ import { db, READ_PREFERENCE_PRIMARY, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import { promiseMapWithLimit } from '@overleaf/promise-utils' async function getDeletedProject(projectId, readPreference) { diff --git a/services/web/scripts/delete_orphaned_docs_online_check.mjs b/services/web/scripts/delete_orphaned_docs_online_check.mjs index 2da28b6a78..d90ef64e75 100644 --- a/services/web/scripts/delete_orphaned_docs_online_check.mjs +++ b/services/web/scripts/delete_orphaned_docs_online_check.mjs @@ -5,7 +5,7 @@ import { db, READ_PREFERENCE_PRIMARY, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import { promiseMapWithLimit } from '@overleaf/promise-utils' import DeleteOrphanedDataHelper from './delete_orphaned_data_helper.mjs' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/e2e_test_setup.mjs b/services/web/scripts/e2e_test_setup.mjs index 3667b83649..4fae1fcade 100644 --- a/services/web/scripts/e2e_test_setup.mjs +++ b/services/web/scripts/e2e_test_setup.mjs @@ -3,8 +3,8 @@ import Path from 'node:path' import { fileURLToPath } from 'node:url' import { promiseMapWithLimit } from '@overleaf/promise-utils' import Settings from '@overleaf/settings' -import { db } from '../app/src/infrastructure/mongodb.mjs' -import GracefulShutdown from '../app/src/infrastructure/GracefulShutdown.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' +import GracefulShutdown from '../app/src/infrastructure/GracefulShutdown.js' import ProjectDeleter from '../app/src/Features/Project/ProjectDeleter.mjs' import SplitTestManager from '../app/src/Features/SplitTests/SplitTestManager.mjs' import UserDeleter from '../app/src/Features/User/UserDeleter.mjs' diff --git a/services/web/scripts/find_malformed_filetrees.mjs b/services/web/scripts/find_malformed_filetrees.mjs index d4c6979167..9f0f6323ab 100644 --- a/services/web/scripts/find_malformed_filetrees.mjs +++ b/services/web/scripts/find_malformed_filetrees.mjs @@ -1,5 +1,5 @@ // @ts-check -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/fix_collaborator_refs_null.mjs b/services/web/scripts/fix_collaborator_refs_null.mjs index fbd4ac89a4..062662a5f8 100644 --- a/services/web/scripts/fix_collaborator_refs_null.mjs +++ b/services/web/scripts/fix_collaborator_refs_null.mjs @@ -3,7 +3,7 @@ import { db, ObjectId, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import lodash from 'lodash' const args = minimist(process.argv.slice(2), { diff --git a/services/web/scripts/fix_comment_id.mjs b/services/web/scripts/fix_comment_id.mjs index a073e33102..5aa933a634 100644 --- a/services/web/scripts/fix_comment_id.mjs +++ b/services/web/scripts/fix_comment_id.mjs @@ -2,7 +2,7 @@ import minimist from 'minimist' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' const OPTS = parseArgs() diff --git a/services/web/scripts/fix_group_invite_emails_to_lowercase.mjs b/services/web/scripts/fix_group_invite_emails_to_lowercase.mjs index 52b98597b4..a9bc0636d7 100644 --- a/services/web/scripts/fix_group_invite_emails_to_lowercase.mjs +++ b/services/web/scripts/fix_group_invite_emails_to_lowercase.mjs @@ -1,4 +1,4 @@ -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/fix_malformed_filetree.mjs b/services/web/scripts/fix_malformed_filetree.mjs index 0e0ea8438e..edaeeee612 100644 --- a/services/web/scripts/fix_malformed_filetree.mjs +++ b/services/web/scripts/fix_malformed_filetree.mjs @@ -7,7 +7,7 @@ * Alternatively, use an adhoc file: --logs=<(echo '{"projectId":"...","path":"..."}') */ import mongodb from 'mongodb-legacy' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import ProjectLocator from '../app/src/Features/Project/ProjectLocator.mjs' import minimist from 'minimist' import readline from 'node:readline' diff --git a/services/web/scripts/fix_oversized_docs.mjs b/services/web/scripts/fix_oversized_docs.mjs index 65395a93fc..ea6b6533ad 100644 --- a/services/web/scripts/fix_oversized_docs.mjs +++ b/services/web/scripts/fix_oversized_docs.mjs @@ -1,9 +1,9 @@ import fs from 'node:fs' import minimist from 'minimist' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.mjs' import FileStoreHandler from '../app/src/Features/FileStore/FileStoreHandler.mjs' -import FileWriter from '../app/src/infrastructure/FileWriter.mjs' +import FileWriter from '../app/src/infrastructure/FileWriter.js' import ProjectEntityMongoUpdateHandler from '../app/src/Features/Project/ProjectEntityMongoUpdateHandler.mjs' import ProjectLocator from '../app/src/Features/Project/ProjectLocator.mjs' import RedisWrapper from '@overleaf/redis-wrapper' diff --git a/services/web/scripts/force_doc_flush.mjs b/services/web/scripts/force_doc_flush.mjs index 95535f0f54..a4f69e47cf 100644 --- a/services/web/scripts/force_doc_flush.mjs +++ b/services/web/scripts/force_doc_flush.mjs @@ -1,5 +1,5 @@ import mongodb from 'mongodb-legacy' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import DocumentUpdaterHandler from '../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/get_emails_by_ids.mjs b/services/web/scripts/get_emails_by_ids.mjs index c2a816e927..151be8be9a 100644 --- a/services/web/scripts/get_emails_by_ids.mjs +++ b/services/web/scripts/get_emails_by_ids.mjs @@ -6,7 +6,7 @@ import { db, ObjectId, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' /** * This script extracts user emails given a list of newline separated IDs diff --git a/services/web/scripts/history/clean_sl_history_data.mjs b/services/web/scripts/history/clean_sl_history_data.mjs index 8791da6dbb..2b0435f56d 100644 --- a/services/web/scripts/history/clean_sl_history_data.mjs +++ b/services/web/scripts/history/clean_sl_history_data.mjs @@ -1,7 +1,7 @@ import { db, getCollectionInternal, -} from '../../app/src/infrastructure/mongodb.mjs' +} from '../../app/src/infrastructure/mongodb.js' import { ensureMongoTimeout } from '../helpers/env_variable_helper.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' // Ensure default mongo query timeout has been increased 1h diff --git a/services/web/scripts/invalidate_tokens.mjs b/services/web/scripts/invalidate_tokens.mjs index 13da1a7a21..d84c320096 100644 --- a/services/web/scripts/invalidate_tokens.mjs +++ b/services/web/scripts/invalidate_tokens.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import minimist from 'minimist' const argv = minimist(process.argv.slice(2)) const commit = argv.commit !== undefined diff --git a/services/web/scripts/lowercase_institution_user_ids.mjs b/services/web/scripts/lowercase_institution_user_ids.mjs index 779114f163..2e4c3a1434 100644 --- a/services/web/scripts/lowercase_institution_user_ids.mjs +++ b/services/web/scripts/lowercase_institution_user_ids.mjs @@ -1,4 +1,4 @@ -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import minimist from 'minimist' import UserGetter from '../app/src/Features/User/UserGetter.mjs' import fs from 'node:fs' diff --git a/services/web/scripts/merge_group_subscription_members.mjs b/services/web/scripts/merge_group_subscription_members.mjs index 566b424222..c710250965 100644 --- a/services/web/scripts/merge_group_subscription_members.mjs +++ b/services/web/scripts/merge_group_subscription_members.mjs @@ -6,7 +6,7 @@ // node scripts/merge_group_subscription_members \ // --target [targetSubscriptionId] --source [sourceSubscriptionId] --commit -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import SubscriptionUpdater from '../app/src/Features/Subscription/SubscriptionUpdater.mjs' import minimist from 'minimist' diff --git a/services/web/scripts/oauth/backfill_hashed_secrets.mjs b/services/web/scripts/oauth/backfill_hashed_secrets.mjs index 06362bdea9..f7b66f881a 100644 --- a/services/web/scripts/oauth/backfill_hashed_secrets.mjs +++ b/services/web/scripts/oauth/backfill_hashed_secrets.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../../app/src/infrastructure/mongodb.mjs' +} from '../../app/src/infrastructure/mongodb.js' import { hashSecret } from '../../modules/oauth2-server/app/src/SecretsHelper.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' diff --git a/services/web/scripts/oauth/create_token.mjs b/services/web/scripts/oauth/create_token.mjs index 1484d91887..e253d1f747 100644 --- a/services/web/scripts/oauth/create_token.mjs +++ b/services/web/scripts/oauth/create_token.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import { hashSecret } from '../../modules/oauth2-server/app/src/SecretsHelper.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' diff --git a/services/web/scripts/oauth/register_client.mjs b/services/web/scripts/oauth/register_client.mjs index fa8868920a..05d4f92ab9 100644 --- a/services/web/scripts/oauth/register_client.mjs +++ b/services/web/scripts/oauth/register_client.mjs @@ -1,6 +1,6 @@ import minimist from 'minimist' import mongodb from 'mongodb-legacy' -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import { hashSecret } from '../../modules/oauth2-server/app/src/SecretsHelper.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' diff --git a/services/web/scripts/oauth/remove_client.mjs b/services/web/scripts/oauth/remove_client.mjs index 6b805301cc..24080491b2 100644 --- a/services/web/scripts/oauth/remove_client.mjs +++ b/services/web/scripts/oauth/remove_client.mjs @@ -2,7 +2,7 @@ import minimist from 'minimist' import { db, READ_PREFERENCE_SECONDARY, -} from '../../app/src/infrastructure/mongodb.mjs' +} from '../../app/src/infrastructure/mongodb.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' async function main() { diff --git a/services/web/scripts/oauth/upgrade_token_scopes.mjs b/services/web/scripts/oauth/upgrade_token_scopes.mjs index 44c5655bed..f28417c1ec 100644 --- a/services/web/scripts/oauth/upgrade_token_scopes.mjs +++ b/services/web/scripts/oauth/upgrade_token_scopes.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' const OPTS = parseArgs() diff --git a/services/web/scripts/recover_docs_from_redis.mjs b/services/web/scripts/recover_docs_from_redis.mjs index faae5141bc..4e5a4ae285 100644 --- a/services/web/scripts/recover_docs_from_redis.mjs +++ b/services/web/scripts/recover_docs_from_redis.mjs @@ -2,7 +2,7 @@ import minimist from 'minimist' -import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import ProjectEntityUpdateHandler from '../app/src/Features/Project/ProjectEntityUpdateHandler.mjs' import ProjectEntityRestoreHandler from '../app/src/Features/Project/ProjectEntityRestoreHandler.mjs' import RedisWrapper from '@overleaf/redis-wrapper' diff --git a/services/web/scripts/recurly/set_manually_collected_subscriptions.mjs b/services/web/scripts/recurly/set_manually_collected_subscriptions.mjs index 7c7ce9c9ff..ab35c1535e 100644 --- a/services/web/scripts/recurly/set_manually_collected_subscriptions.mjs +++ b/services/web/scripts/recurly/set_manually_collected_subscriptions.mjs @@ -5,7 +5,7 @@ import minimist from 'minimist' import { db, READ_PREFERENCE_SECONDARY, -} from '../../app/src/infrastructure/mongodb.mjs' +} from '../../app/src/infrastructure/mongodb.js' /** * @import { ObjectId } from 'mongodb-legacy' diff --git a/services/web/scripts/refresh_features.mjs b/services/web/scripts/refresh_features.mjs index c1f7e6a8d2..23c6ad44cb 100644 --- a/services/web/scripts/refresh_features.mjs +++ b/services/web/scripts/refresh_features.mjs @@ -1,4 +1,4 @@ -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import minimist from 'minimist' import _ from 'lodash' import async from 'async' diff --git a/services/web/scripts/regenerate_duplicate_referral_ids.mjs b/services/web/scripts/regenerate_duplicate_referral_ids.mjs index 7b5666aede..84f3a7f61e 100644 --- a/services/web/scripts/regenerate_duplicate_referral_ids.mjs +++ b/services/web/scripts/regenerate_duplicate_referral_ids.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import { promiseMapWithLimit } from '@overleaf/promise-utils' import TokenGenerator from '../app/src/Features/TokenGenerator/TokenGenerator.mjs' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' diff --git a/services/web/scripts/remove_email.mjs b/services/web/scripts/remove_email.mjs index 32600484f0..4f85807b4b 100644 --- a/services/web/scripts/remove_email.mjs +++ b/services/web/scripts/remove_email.mjs @@ -1,4 +1,4 @@ -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import UserUpdater from '../app/src/Features/User/UserUpdater.mjs' import UserGetter from '../app/src/Features/User/UserGetter.mjs' diff --git a/services/web/scripts/remove_feature_from_all_users.mjs b/services/web/scripts/remove_feature_from_all_users.mjs index 5380852bfa..f138501f0e 100644 --- a/services/web/scripts/remove_feature_from_all_users.mjs +++ b/services/web/scripts/remove_feature_from_all_users.mjs @@ -1,7 +1,7 @@ import { db, READ_PREFERENCE_SECONDARY, -} from '../app/src/infrastructure/mongodb.mjs' +} from '../app/src/infrastructure/mongodb.js' import parseArgs from 'minimist' import { scriptRunner } from './lib/ScriptRunner.mjs' diff --git a/services/web/scripts/remove_user_enrollment.mjs b/services/web/scripts/remove_user_enrollment.mjs index e8e112af1c..64073607a9 100644 --- a/services/web/scripts/remove_user_enrollment.mjs +++ b/services/web/scripts/remove_user_enrollment.mjs @@ -6,7 +6,7 @@ // $ node scripts/remove_user_enrollment.mjs --id USER_ID --commit import minimist from 'minimist' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { User } from '../app/src/models/User.mjs' import { Subscription } from '../app/src/models/Subscription.mjs' import UserAuditLogHandler from '../app/src/Features/User/UserAuditLogHandler.mjs' diff --git a/services/web/scripts/reset_rolling_build_update_notification.mjs b/services/web/scripts/reset_rolling_build_update_notification.mjs index b9570f6e4c..89044949fa 100644 --- a/services/web/scripts/reset_rolling_build_update_notification.mjs +++ b/services/web/scripts/reset_rolling_build_update_notification.mjs @@ -1,5 +1,5 @@ import { scriptRunner } from './lib/ScriptRunner.mjs' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' import minimist from 'minimist' const argv = minimist(process.argv.slice(2)) diff --git a/services/web/scripts/stress_test.mjs b/services/web/scripts/stress_test.mjs index eb353b655a..47fa90c6eb 100644 --- a/services/web/scripts/stress_test.mjs +++ b/services/web/scripts/stress_test.mjs @@ -1,8 +1,8 @@ import minimist from 'minimist' import settings from '@overleaf/settings' import ProjectDetailsHandler from '../app/src/Features/Project/ProjectDetailsHandler.mjs' -import mongodb from '../app/src/infrastructure/mongodb.mjs' -import mongoose from '../app/src/infrastructure/Mongoose.mjs' +import mongodb from '../app/src/infrastructure/mongodb.js' +import mongoose from '../app/src/infrastructure/Mongoose.js' import fs from 'node:fs' import path from 'node:path' import crypto from 'node:crypto' diff --git a/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs b/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs index f2327be9e2..de702602ea 100644 --- a/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs +++ b/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs @@ -26,7 +26,7 @@ */ import minimist from 'minimist' -import { z } from '../../app/src/infrastructure/Validation.mjs' +import { z } from '../../app/src/infrastructure/Validation.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient, diff --git a/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs b/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs index 0597460a00..c2425b6ddd 100644 --- a/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs +++ b/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs @@ -26,7 +26,7 @@ */ import minimist from 'minimist' -import { z } from '../../app/src/infrastructure/Validation.mjs' +import { z } from '../../app/src/infrastructure/Validation.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' diff --git a/services/web/scripts/suspend_users.mjs b/services/web/scripts/suspend_users.mjs index e7927b6f33..76d7eef2ca 100644 --- a/services/web/scripts/suspend_users.mjs +++ b/services/web/scripts/suspend_users.mjs @@ -4,7 +4,7 @@ * Usage: node scripts/suspend_users.mjs */ import fs from 'node:fs' -import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' +import { ObjectId } from '../app/src/infrastructure/mongodb.js' import UserUpdater from '../app/src/Features/User/UserUpdater.mjs' import { promiseMapWithLimit } from '@overleaf/promise-utils' diff --git a/services/web/scripts/update_project_image_name.mjs b/services/web/scripts/update_project_image_name.mjs index d678dbf5cd..dad141b8f1 100644 --- a/services/web/scripts/update_project_image_name.mjs +++ b/services/web/scripts/update_project_image_name.mjs @@ -1,5 +1,5 @@ import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const oldImage = process.argv[2] const newImage = process.argv[3] diff --git a/services/web/scripts/validate-data-of-model.mjs b/services/web/scripts/validate-data-of-model.mjs index 30746b6eec..63788bef6d 100644 --- a/services/web/scripts/validate-data-of-model.mjs +++ b/services/web/scripts/validate-data-of-model.mjs @@ -1,5 +1,5 @@ import { batchedUpdateWithResultHandling } from '@overleaf/mongo-utils/batchedUpdate.js' -import { db } from '../app/src/infrastructure/mongodb.mjs' +import { db } from '../app/src/infrastructure/mongodb.js' const MODEL_NAME = process.argv.pop() diff --git a/services/web/scripts/writefull/back_fill_hiding_ai_features.mjs b/services/web/scripts/writefull/back_fill_hiding_ai_features.mjs index 60e74304fe..e40e065d51 100644 --- a/services/web/scripts/writefull/back_fill_hiding_ai_features.mjs +++ b/services/web/scripts/writefull/back_fill_hiding_ai_features.mjs @@ -1,4 +1,4 @@ -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import { scriptRunner } from '../lib/ScriptRunner.mjs' diff --git a/services/web/scripts/writefull/enable_wf_autoCreatedAccount.mjs b/services/web/scripts/writefull/enable_wf_autoCreatedAccount.mjs index 19940237cc..bdae9d8f26 100644 --- a/services/web/scripts/writefull/enable_wf_autoCreatedAccount.mjs +++ b/services/web/scripts/writefull/enable_wf_autoCreatedAccount.mjs @@ -1,4 +1,4 @@ -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import mongodb from 'mongodb-legacy' import fs from 'node:fs' import { fileURLToPath } from 'node:url' diff --git a/services/web/scripts/writefull/enable_writefull_without_autoCreatedAccount.mjs b/services/web/scripts/writefull/enable_writefull_without_autoCreatedAccount.mjs index 9f31b18224..8f76ad666d 100644 --- a/services/web/scripts/writefull/enable_writefull_without_autoCreatedAccount.mjs +++ b/services/web/scripts/writefull/enable_writefull_without_autoCreatedAccount.mjs @@ -1,4 +1,4 @@ -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import mongodb from 'mongodb-legacy' import fs from 'node:fs' import { fileURLToPath } from 'node:url' diff --git a/services/web/scripts/writefull/split_writefull_disabled_from_unset.mjs b/services/web/scripts/writefull/split_writefull_disabled_from_unset.mjs index 6428920926..dc86f8897b 100644 --- a/services/web/scripts/writefull/split_writefull_disabled_from_unset.mjs +++ b/services/web/scripts/writefull/split_writefull_disabled_from_unset.mjs @@ -1,4 +1,4 @@ -import { db } from '../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../app/src/infrastructure/mongodb.js' import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' import mongodb from 'mongodb-legacy' import fs from 'node:fs' diff --git a/services/web/test/acceptance/src/AddSecondaryEmailTests.mjs b/services/web/test/acceptance/src/AddSecondaryEmailTests.mjs index 4554ce2d46..d56d7e877e 100644 --- a/services/web/test/acceptance/src/AddSecondaryEmailTests.mjs +++ b/services/web/test/acceptance/src/AddSecondaryEmailTests.mjs @@ -2,7 +2,7 @@ import { expect } from 'chai' import UserHelper from './helpers/User.mjs' import logger from '@overleaf/logger' import sinon from 'sinon' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import Features from '../../../app/src/infrastructure/Features.mjs' const User = UserHelper.promises diff --git a/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.mjs b/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.mjs index 7c4a76be4c..599e684447 100644 --- a/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.mjs +++ b/services/web/test/acceptance/src/BackFillDocNameForDeletedDocsTests.mjs @@ -2,7 +2,7 @@ import { exec } from 'node:child_process' import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' import UserHelper from './helpers/User.mjs' import { renderObjectId } from '@overleaf/mongo-utils/batchedUpdate.js' diff --git a/services/web/test/acceptance/src/BackFillDocRevTests.mjs b/services/web/test/acceptance/src/BackFillDocRevTests.mjs index 90fc37c6c1..ad15f2fed5 100644 --- a/services/web/test/acceptance/src/BackFillDocRevTests.mjs +++ b/services/web/test/acceptance/src/BackFillDocRevTests.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' import { promisify } from 'node:util' import { exec } from 'node:child_process' import logger from '@overleaf/logger' diff --git a/services/web/test/acceptance/src/BackFillDummyDocMetaTests.mjs b/services/web/test/acceptance/src/BackFillDummyDocMetaTests.mjs index 0759a2da0f..1b82b129d3 100644 --- a/services/web/test/acceptance/src/BackFillDummyDocMetaTests.mjs +++ b/services/web/test/acceptance/src/BackFillDummyDocMetaTests.mjs @@ -3,7 +3,7 @@ import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' import { filterOutput } from './helpers/settings.mjs' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' const DUMMY_NAME = 'unknown.tex' const DUMMY_TIME = new Date('2021-04-12T00:00:00.000Z') diff --git a/services/web/test/acceptance/src/BatchedUpdateTests.mjs b/services/web/test/acceptance/src/BatchedUpdateTests.mjs index eaa222605b..e93881dcf6 100644 --- a/services/web/test/acceptance/src/BatchedUpdateTests.mjs +++ b/services/web/test/acceptance/src/BatchedUpdateTests.mjs @@ -1,6 +1,6 @@ import { spawnSync } from 'node:child_process' import { expect } from 'chai' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' describe('BatchedUpdateTests', function () { it('can handle non linear insert order', async function () { @@ -24,7 +24,7 @@ describe('BatchedUpdateTests', function () { spawnSync(process.argv0, [ '--input-type=module', '-e', - 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.mjs"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', ]) await expect( @@ -56,7 +56,7 @@ describe('BatchedUpdateTests', function () { [ '--input-type=module', '-e', - 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.mjs"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', ], { encoding: 'utf-8' } ) @@ -93,7 +93,7 @@ describe('BatchedUpdateTests', function () { [ '--input-type=module', '-e', - 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.mjs"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', ], { encoding: 'utf-8', @@ -141,7 +141,7 @@ describe('BatchedUpdateTests', function () { [ '--input-type=module', '-e', - 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.mjs"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + 'import { batchedUpdateWithResultHandling } from "@overleaf/mongo-utils/batchedUpdate.js"; import { db } from "./app/src/infrastructure/mongodb.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', ], { env: { diff --git a/services/web/test/acceptance/src/CaptchaTests.mjs b/services/web/test/acceptance/src/CaptchaTests.mjs index 7774492e31..223fe02cb0 100644 --- a/services/web/test/acceptance/src/CaptchaTests.mjs +++ b/services/web/test/acceptance/src/CaptchaTests.mjs @@ -1,4 +1,4 @@ -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import { expect } from 'chai' import Settings from '@overleaf/settings' import UserHelper from './helpers/User.mjs' diff --git a/services/web/test/acceptance/src/ClearSessionsSetMustReconfirmTests.mjs b/services/web/test/acceptance/src/ClearSessionsSetMustReconfirmTests.mjs index b8dbbe21c5..1070bad11b 100644 --- a/services/web/test/acceptance/src/ClearSessionsSetMustReconfirmTests.mjs +++ b/services/web/test/acceptance/src/ClearSessionsSetMustReconfirmTests.mjs @@ -2,7 +2,7 @@ import { exec } from 'node:child_process' import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' -import { ObjectId, db } from '../../../app/src/infrastructure/mongodb.mjs' +import { ObjectId, db } from '../../../app/src/infrastructure/mongodb.js' import fs from 'node:fs/promises' import UserHelper from './helpers/User.mjs' import UserGetter from '../../../app/src/Features/User/UserGetter.mjs' diff --git a/services/web/test/acceptance/src/ConvertEmailConfirmedAtToDates.mjs b/services/web/test/acceptance/src/ConvertEmailConfirmedAtToDates.mjs index f04dfaccd6..5fa88b6fb3 100644 --- a/services/web/test/acceptance/src/ConvertEmailConfirmedAtToDates.mjs +++ b/services/web/test/acceptance/src/ConvertEmailConfirmedAtToDates.mjs @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import { exec } from 'node:child_process' describe('ConvertEmailConfirmedAtToDates', function () { diff --git a/services/web/test/acceptance/src/ConvertSplitTestAssignedAtToDates.mjs b/services/web/test/acceptance/src/ConvertSplitTestAssignedAtToDates.mjs index b5fd0433d8..1f27726876 100644 --- a/services/web/test/acceptance/src/ConvertSplitTestAssignedAtToDates.mjs +++ b/services/web/test/acceptance/src/ConvertSplitTestAssignedAtToDates.mjs @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import { exec } from 'node:child_process' describe('ConvertSplitTestAssignedAtToDates', function () { diff --git a/services/web/test/acceptance/src/DeleteOrphanedDocsOnlineCheckTests.mjs b/services/web/test/acceptance/src/DeleteOrphanedDocsOnlineCheckTests.mjs index 8e951c5554..fc69d7750a 100644 --- a/services/web/test/acceptance/src/DeleteOrphanedDocsOnlineCheckTests.mjs +++ b/services/web/test/acceptance/src/DeleteOrphanedDocsOnlineCheckTests.mjs @@ -3,7 +3,7 @@ import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' import { filterOutput } from './helpers/settings.mjs' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' const ONE_DAY_IN_S = 60 * 60 * 24 const BATCH_SIZE = 3 diff --git a/services/web/test/acceptance/src/DeletionTests.mjs b/services/web/test/acceptance/src/DeletionTests.mjs index b693c9b96d..39d1ba053d 100644 --- a/services/web/test/acceptance/src/DeletionTests.mjs +++ b/services/web/test/acceptance/src/DeletionTests.mjs @@ -6,7 +6,7 @@ import request from './helpers/request.js' import async from 'async' import { expect } from 'chai' import settings from '@overleaf/settings' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' import Features from '../../../app/src/infrastructure/Features.mjs' import MockDocstoreApiClass from './mocks/MockDocstoreApi.mjs' import MockChatApiClass from './mocks/MockChatApi.mjs' diff --git a/services/web/test/acceptance/src/HaveIBeenPwnedApiTests.mjs b/services/web/test/acceptance/src/HaveIBeenPwnedApiTests.mjs index 422a95489b..ffa8eb7618 100644 --- a/services/web/test/acceptance/src/HaveIBeenPwnedApiTests.mjs +++ b/services/web/test/acceptance/src/HaveIBeenPwnedApiTests.mjs @@ -2,7 +2,7 @@ import Settings from '@overleaf/settings' import { expect } from 'chai' import UserHelper from './helpers/User.mjs' import MockHaveIBeenPwnedApiClass from './mocks/MockHaveIBeenPwnedApi.mjs' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import MetricsHelper from './helpers/metrics.mjs' const User = UserHelper.promises diff --git a/services/web/test/acceptance/src/LinkedFilesTests.mjs b/services/web/test/acceptance/src/LinkedFilesTests.mjs index cc25097d3e..8010aac407 100644 --- a/services/web/test/acceptance/src/LinkedFilesTests.mjs +++ b/services/web/test/acceptance/src/LinkedFilesTests.mjs @@ -4,7 +4,7 @@ import timekeeper from 'timekeeper' import Settings from '@overleaf/settings' import UserHelper from './helpers/User.mjs' import express from 'express' -import { plainTextResponse } from '../../../app/src/infrastructure/Response.mjs' +import { plainTextResponse } from '../../../app/src/infrastructure/Response.js' const User = UserHelper.promises diff --git a/services/web/test/acceptance/src/MalformedFiletreesTests.mjs b/services/web/test/acceptance/src/MalformedFiletreesTests.mjs index 63f60ffff4..16282d592d 100644 --- a/services/web/test/acceptance/src/MalformedFiletreesTests.mjs +++ b/services/web/test/acceptance/src/MalformedFiletreesTests.mjs @@ -3,7 +3,7 @@ import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' import { filterOutput } from './helpers/settings.mjs' -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' const lastUpdated = new Date(42) const lastUpdatedBy = new ObjectId() diff --git a/services/web/test/acceptance/src/MongoHelper.mjs b/services/web/test/acceptance/src/MongoHelper.mjs index ca22cecc3e..1821477bdf 100644 --- a/services/web/test/acceptance/src/MongoHelper.mjs +++ b/services/web/test/acceptance/src/MongoHelper.mjs @@ -2,7 +2,7 @@ import { expect } from 'chai' import mongodb from 'mongodb-legacy' import mongoose from 'mongoose' import { User as UserModel } from '../../../app/src/models/User.mjs' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import MongoHelpers from '../../../app/src/Features/Helpers/Mongo.mjs' import UserHelper from './helpers/User.mjs' diff --git a/services/web/test/acceptance/src/PasswordResetTests.mjs b/services/web/test/acceptance/src/PasswordResetTests.mjs index e7900993db..4e4cf9c5c1 100644 --- a/services/web/test/acceptance/src/PasswordResetTests.mjs +++ b/services/web/test/acceptance/src/PasswordResetTests.mjs @@ -1,6 +1,6 @@ import { expect } from 'chai' import UserHelper from './helpers/UserHelper.mjs' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' describe('PasswordReset', function () { let email, response, user, userHelper, token, emailQuery diff --git a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.mjs b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.mjs index 6c21681e65..33d8610f49 100644 --- a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.mjs +++ b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.mjs @@ -12,7 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -import LockManager from '../../../app/src/infrastructure/LockManager.mjs' +import LockManager from '../../../app/src/infrastructure/LockManager.js' import ProjectCreationHandler from '../../../app/src/Features/Project/ProjectCreationHandler.mjs' import ProjectGetter from '../../../app/src/Features/Project/ProjectGetter.mjs' diff --git a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.mjs b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.mjs index bcb6d1b963..801ebfd455 100644 --- a/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.mjs +++ b/services/web/test/acceptance/src/RegenerateDuplicateReferralIdsTests.mjs @@ -3,7 +3,7 @@ import { promisify } from 'node:util' import { expect } from 'chai' import logger from '@overleaf/logger' import { filterOutput } from './helpers/settings.mjs' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import { renderObjectId } from '@overleaf/mongo-utils/batchedUpdate.js' const BATCH_SIZE = 100 diff --git a/services/web/test/acceptance/src/RemoveDeletedUsersFromTokenAccessRefsTests.mjs b/services/web/test/acceptance/src/RemoveDeletedUsersFromTokenAccessRefsTests.mjs index 1f14faa689..7aa0c895d6 100644 --- a/services/web/test/acceptance/src/RemoveDeletedUsersFromTokenAccessRefsTests.mjs +++ b/services/web/test/acceptance/src/RemoveDeletedUsersFromTokenAccessRefsTests.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js' import { promisify } from 'node:util' import { exec } from 'node:child_process' import logger from '@overleaf/logger' diff --git a/services/web/test/acceptance/src/TokenAccessTests.mjs b/services/web/test/acceptance/src/TokenAccessTests.mjs index a3f4c5c9a9..1ffba5dfd5 100644 --- a/services/web/test/acceptance/src/TokenAccessTests.mjs +++ b/services/web/test/acceptance/src/TokenAccessTests.mjs @@ -3,7 +3,7 @@ import async from 'async' import User from './helpers/User.mjs' import request from './helpers/request.js' import settings from '@overleaf/settings' -import { db } from '../../../app/src/infrastructure/mongodb.mjs' +import { db } from '../../../app/src/infrastructure/mongodb.js' import expectErrorResponse from './helpers/expectErrorResponse.mjs' import logger from '@overleaf/logger' import sinon from 'sinon' diff --git a/services/web/test/acceptance/src/helpers/InitApp.mjs b/services/web/test/acceptance/src/helpers/InitApp.mjs index a85e050c16..b2544a43cf 100644 --- a/services/web/test/acceptance/src/helpers/InitApp.mjs +++ b/services/web/test/acceptance/src/helpers/InitApp.mjs @@ -4,12 +4,12 @@ import MongoHelper from './MongoHelper.mjs' import RedisHelper from './RedisHelper.mjs' import Settings from '@overleaf/settings' import MockReCAPTCHAApi from '../mocks/MockReCaptchaApi.mjs' -import { gracefulShutdown } from '../../../../app/src/infrastructure/GracefulShutdown.mjs' +import { gracefulShutdown } from '../../../../app/src/infrastructure/GracefulShutdown.js' import Server from '../../../../app/src/infrastructure/Server.mjs' import { injectRouteAfter } from './injectRoute.mjs' import SplitTestHandler from '../../../../app/src/Features/SplitTests/SplitTestHandler.mjs' import SplitTestSessionHandler from '../../../../app/src/Features/SplitTests/SplitTestSessionHandler.mjs' -import Modules from '../../../../app/src/infrastructure/Modules.mjs' +import Modules from '../../../../app/src/infrastructure/Modules.js' const app = Server.app diff --git a/services/web/test/acceptance/src/helpers/MongoHelper.mjs b/services/web/test/acceptance/src/helpers/MongoHelper.mjs index 35ce209ea1..0351c09a31 100644 --- a/services/web/test/acceptance/src/helpers/MongoHelper.mjs +++ b/services/web/test/acceptance/src/helpers/MongoHelper.mjs @@ -3,7 +3,7 @@ import { connectionPromise, cleanupTestDatabase, dropTestDatabase, -} from '../../../../app/src/infrastructure/mongodb.mjs' +} from '../../../../app/src/infrastructure/mongodb.js' import Settings from '@overleaf/settings' import { promisify } from 'node:util' diff --git a/services/web/test/acceptance/src/helpers/RedisHelper.mjs b/services/web/test/acceptance/src/helpers/RedisHelper.mjs index 33fdfbbbbc..e38d7ad80e 100644 --- a/services/web/test/acceptance/src/helpers/RedisHelper.mjs +++ b/services/web/test/acceptance/src/helpers/RedisHelper.mjs @@ -1,4 +1,4 @@ -import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.mjs' +import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.js' const client = RedisWrapper.client('ratelimiter') export default { diff --git a/services/web/test/acceptance/src/helpers/Subscription.mjs b/services/web/test/acceptance/src/helpers/Subscription.mjs index 48aa2f7b60..afa1297de0 100644 --- a/services/web/test/acceptance/src/helpers/Subscription.mjs +++ b/services/web/test/acceptance/src/helpers/Subscription.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.js' import { expect } from 'chai' import { callbackifyClass } from '@overleaf/promise-utils' import SubscriptionUpdater from '../../../../app/src/Features/Subscription/SubscriptionUpdater.mjs' @@ -6,7 +6,7 @@ import PermissionsManager from '../../../../app/src/Features/Authorization/Permi import SSOConfigManager from '../../../../modules/group-settings/app/src/sso/SSOConfigManager.mjs' import { Subscription as SubscriptionModel } from '../../../../app/src/models/Subscription.mjs' import { DeletedSubscription as DeletedSubscriptionModel } from '../../../../app/src/models/DeletedSubscription.mjs' -import Modules from '../../../../app/src/infrastructure/Modules.mjs' +import Modules from '../../../../app/src/infrastructure/Modules.js' class PromisifiedSubscription { constructor(options = {}) { diff --git a/services/web/test/acceptance/src/helpers/User.mjs b/services/web/test/acceptance/src/helpers/User.mjs index f9010d69fd..3bc4d801f1 100644 --- a/services/web/test/acceptance/src/helpers/User.mjs +++ b/services/web/test/acceptance/src/helpers/User.mjs @@ -1,7 +1,7 @@ import OError from '@overleaf/o-error' import request from './request.js' import settings from '@overleaf/settings' -import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.js' import { User as UserModel } from '../../../../app/src/models/User.mjs' import UserUpdater from '../../../../app/src/Features/User/UserUpdater.mjs' import AuthenticationManager from '../../../../app/src/Features/Authentication/AuthenticationManager.mjs' diff --git a/services/web/test/acceptance/src/helpers/UserHelper.mjs b/services/web/test/acceptance/src/helpers/UserHelper.mjs index b7332f5c3a..d14d41c4c3 100644 --- a/services/web/test/acceptance/src/helpers/UserHelper.mjs +++ b/services/web/test/acceptance/src/helpers/UserHelper.mjs @@ -13,7 +13,7 @@ import { UserAuditLogEntry } from '../../../../app/src/models/UserAuditLogEntry. // Import the rate limiter so we can clear it between tests -import { RateLimiter } from '../../../../app/src/infrastructure/RateLimiter.mjs' +import { RateLimiter } from '../../../../app/src/infrastructure/RateLimiter.js' const { ObjectId } = mongodb diff --git a/services/web/test/acceptance/src/mocks/MockClsiApi.mjs b/services/web/test/acceptance/src/mocks/MockClsiApi.mjs index 32db8f1847..de2fc488c0 100644 --- a/services/web/test/acceptance/src/mocks/MockClsiApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockClsiApi.mjs @@ -1,5 +1,5 @@ import AbstractMockApi from './AbstractMockApi.mjs' -import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.js' class MockClsiApi extends AbstractMockApi { static compile(req, res) { diff --git a/services/web/test/acceptance/src/mocks/MockDocstoreApi.mjs b/services/web/test/acceptance/src/mocks/MockDocstoreApi.mjs index b3726a4524..3a73e62dc0 100644 --- a/services/web/test/acceptance/src/mocks/MockDocstoreApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockDocstoreApi.mjs @@ -1,4 +1,4 @@ -import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.js' import AbstractMockApi from './AbstractMockApi.mjs' class MockDocstoreApi extends AbstractMockApi { diff --git a/services/web/test/acceptance/src/mocks/MockHaveIBeenPwnedApi.mjs b/services/web/test/acceptance/src/mocks/MockHaveIBeenPwnedApi.mjs index 0425d986e5..2aa47f83f7 100644 --- a/services/web/test/acceptance/src/mocks/MockHaveIBeenPwnedApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockHaveIBeenPwnedApi.mjs @@ -1,5 +1,5 @@ import AbstractMockApi from './AbstractMockApi.mjs' -import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.js' class MockHaveIBeenPwnedApi extends AbstractMockApi { reset() { diff --git a/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.mjs b/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.mjs index 7ff95ec395..82908dc948 100644 --- a/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockProjectHistoryApi.mjs @@ -1,7 +1,7 @@ import AbstractMockApi from './AbstractMockApi.mjs' import _ from 'lodash' import mongodb from 'mongodb-legacy' -import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.js' const { ObjectId } = mongodb diff --git a/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs b/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs index d25789d92c..9876b86eda 100644 --- a/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs @@ -1,6 +1,6 @@ import AbstractMockApi from './AbstractMockApi.mjs' import SubscriptionController from '../../../../app/src/Features/Subscription/SubscriptionController.mjs' -import { xmlResponse } from '../../../../app/src/infrastructure/Response.mjs' +import { xmlResponse } from '../../../../app/src/infrastructure/Response.js' class MockRecurlyApi extends AbstractMockApi { reset() { diff --git a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.mjs b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.mjs index 3b424c7774..620b073317 100644 --- a/services/web/test/acceptance/src/mocks/MockV1HistoryApi.mjs +++ b/services/web/test/acceptance/src/mocks/MockV1HistoryApi.mjs @@ -3,7 +3,7 @@ import { EventEmitter } from 'node:events' import { zipAttachment, prepareZipAttachment, -} from '../../../../app/src/infrastructure/Response.mjs' +} from '../../../../app/src/infrastructure/Response.js' import { z } from 'zod' class MockV1HistoryApi extends AbstractMockApi { diff --git a/services/web/test/smoke/src/steps/001_clearRateLimits.mjs b/services/web/test/smoke/src/steps/001_clearRateLimits.mjs index befbe0ec28..953c3fca62 100644 --- a/services/web/test/smoke/src/steps/001_clearRateLimits.mjs +++ b/services/web/test/smoke/src/steps/001_clearRateLimits.mjs @@ -2,7 +2,7 @@ import Settings from '@overleaf/settings' import { overleafLoginRateLimiter, openProjectRateLimiter, -} from '../../../../app/src/infrastructure/RateLimiter.mjs' +} from '../../../../app/src/infrastructure/RateLimiter.js' import LoginRateLimiter from '../../../../app/src/Features/Security/LoginRateLimiter.mjs' async function clearLoginRateLimit() { diff --git a/services/web/test/unit/src/Analytics/AnalyticsManager.test.mjs b/services/web/test/unit/src/Analytics/AnalyticsManager.test.mjs index 423573421f..82c5d741c6 100644 --- a/services/web/test/unit/src/Analytics/AnalyticsManager.test.mjs +++ b/services/web/test/unit/src/Analytics/AnalyticsManager.test.mjs @@ -11,7 +11,7 @@ const MODULE_PATH = path.join( import.meta.dirname, '../../../../app/src/Features/Analytics/AnalyticsManager' ) -vi.mock('../../../../app/src/infrastructure/Metrics.mjs', () => ({ +vi.mock('../../../../app/src/infrastructure/Metrics.js', () => ({ default: { analyticsQueue: { inc: vi.fn(), diff --git a/services/web/test/unit/src/Chat/ChatController.test.mjs b/services/web/test/unit/src/Chat/ChatController.test.mjs index a4912f4cbc..9a66ae0243 100644 --- a/services/web/test/unit/src/Chat/ChatController.test.mjs +++ b/services/web/test/unit/src/Chat/ChatController.test.mjs @@ -62,7 +62,7 @@ describe('ChatController', function () { }) ) - vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.js', () => ({ default: ctx.Modules, })) diff --git a/services/web/test/unit/src/Compile/CompileController.test.mjs b/services/web/test/unit/src/Compile/CompileController.test.mjs index ad74c4dfc3..d715d3e600 100644 --- a/services/web/test/unit/src/Compile/CompileController.test.mjs +++ b/services/web/test/unit/src/Compile/CompileController.test.mjs @@ -133,7 +133,7 @@ describe('CompileController', function () { ) vi.doMock( - '../../../../app/src/infrastructure/RateLimiter.mjs', + '../../../../app/src/infrastructure/RateLimiter.js', () => ctx.RateLimiter ) diff --git a/services/web/test/unit/src/Compile/CompileManager.test.mjs b/services/web/test/unit/src/Compile/CompileManager.test.mjs index a7f856d996..9e221eb573 100644 --- a/services/web/test/unit/src/Compile/CompileManager.test.mjs +++ b/services/web/test/unit/src/Compile/CompileManager.test.mjs @@ -56,7 +56,7 @@ describe('CompileManager', function () { default: (ctx.ClsiManager = { promises: {} }), })) - vi.doMock('../../../../app/src/infrastructure/RateLimiter.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/RateLimiter.js', () => ({ RateLimiter: sinon.stub().returns(ctx.rateLimiter), })) diff --git a/services/web/test/unit/src/Cooldown/CooldownManager.sequential.test.mjs b/services/web/test/unit/src/Cooldown/CooldownManager.sequential.test.mjs index 5c6640c8f4..fdd757f03f 100644 --- a/services/web/test/unit/src/Cooldown/CooldownManager.sequential.test.mjs +++ b/services/web/test/unit/src/Cooldown/CooldownManager.sequential.test.mjs @@ -1,12 +1,12 @@ import { expect } from 'vitest' import mongodb from 'mongodb-legacy' import CooldownManager from '../../../../app/src/Features/Cooldown/CooldownManager.mjs' -import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.mjs' +import { cleanupTestRedis } from '../../../../app/src/infrastructure/RedisWrapper.js' const { ObjectId } = mongodb describe('CooldownManager', function () { - beforeEach(RedisWrapper.cleanupTestRedis) + beforeEach(cleanupTestRedis) beforeEach(function (ctx) { ctx.project1Id = new ObjectId().toString() diff --git a/services/web/test/unit/src/Documents/DocumentController.test.mjs b/services/web/test/unit/src/Documents/DocumentController.test.mjs index 6cd4a7e11a..b683cc5d14 100644 --- a/services/web/test/unit/src/Documents/DocumentController.test.mjs +++ b/services/web/test/unit/src/Documents/DocumentController.test.mjs @@ -121,7 +121,7 @@ describe('DocumentController', function () { default: ctx.ChatApiHandler, })) - vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.js', () => ({ default: ctx.Modules, })) diff --git a/services/web/test/unit/src/Editor/EditorHttpController.test.mjs b/services/web/test/unit/src/Editor/EditorHttpController.test.mjs index 81c5a7b13b..730d9c811a 100644 --- a/services/web/test/unit/src/Editor/EditorHttpController.test.mjs +++ b/services/web/test/unit/src/Editor/EditorHttpController.test.mjs @@ -228,7 +228,7 @@ describe('EditorHttpController', function () { default: ctx.SessionManager, }) ) - vi.doMock('../../../../app/src/infrastructure/FileWriter.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/FileWriter.js', () => ({ default: ctx.FileWriter, })) vi.doMock( diff --git a/services/web/test/unit/src/History/HistoryController.test.mjs b/services/web/test/unit/src/History/HistoryController.test.mjs index 6d409ca120..4a06a1cf59 100644 --- a/services/web/test/unit/src/History/HistoryController.test.mjs +++ b/services/web/test/unit/src/History/HistoryController.test.mjs @@ -71,7 +71,7 @@ describe('HistoryController', function () { default: {}, })) - vi.doMock('../../../../app/src/infrastructure/mongodb.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/mongodb.js', () => ({ default: { ObjectId }, })) diff --git a/services/web/test/unit/src/History/HistoryManager.sequential.test.mjs b/services/web/test/unit/src/History/HistoryManager.sequential.test.mjs index cf5929558e..e8d3ea2052 100644 --- a/services/web/test/unit/src/History/HistoryManager.sequential.test.mjs +++ b/services/web/test/unit/src/History/HistoryManager.sequential.test.mjs @@ -5,7 +5,7 @@ import { cleanupTestDatabase, db, waitForDb, -} from '../../../../app/src/infrastructure/mongodb.mjs' +} from '../../../../app/src/infrastructure/mongodb.js' const { ObjectId } = mongodb diff --git a/services/web/test/unit/src/History/RestoreManager.test.mjs b/services/web/test/unit/src/History/RestoreManager.test.mjs index 450ccae874..e13195af70 100644 --- a/services/web/test/unit/src/History/RestoreManager.test.mjs +++ b/services/web/test/unit/src/History/RestoreManager.test.mjs @@ -82,7 +82,7 @@ describe('RestoreManager', function () { }) ) - vi.doMock('../../../../app/src/infrastructure/Metrics.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/Metrics.js', () => ({ default: { revertFileDurationSeconds: { startTimer: sinon.stub().returns(sinon.stub()), diff --git a/services/web/test/unit/src/Security/OneTimeTokenHandler.sequential.test.mjs b/services/web/test/unit/src/Security/OneTimeTokenHandler.sequential.test.mjs index e7843c8b41..df412f2d39 100644 --- a/services/web/test/unit/src/Security/OneTimeTokenHandler.sequential.test.mjs +++ b/services/web/test/unit/src/Security/OneTimeTokenHandler.sequential.test.mjs @@ -4,7 +4,7 @@ import Errors from '../../../../app/src/Features/Errors/Errors.js' import { connectionPromise, cleanupTestDatabase, -} from '../../../../app/src/infrastructure/mongodb.mjs' +} from '../../../../app/src/infrastructure/mongodb.js' import OneTimeTokenHandler from '../../../../app/src/Features/Security/OneTimeTokenHandler.mjs' vi.mock('../../../../app/src/Features/Errors/Errors.js', () => diff --git a/services/web/test/unit/src/Spelling/LearnedWordsManager.test.mjs b/services/web/test/unit/src/Spelling/LearnedWordsManager.test.mjs index 84bf6d6531..ef45cefa07 100644 --- a/services/web/test/unit/src/Spelling/LearnedWordsManager.test.mjs +++ b/services/web/test/unit/src/Spelling/LearnedWordsManager.test.mjs @@ -18,7 +18,7 @@ describe('LearnedWordsManager', function () { }, } - vi.doMock('../../../../app/src/infrastructure/mongodb.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/mongodb.js', () => ({ default: { db: ctx.db }, })) diff --git a/services/web/test/unit/src/UserMembership/UserMembershipController.test.mjs b/services/web/test/unit/src/UserMembership/UserMembershipController.test.mjs index 5bdd73eef4..7492df2e1a 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipController.test.mjs +++ b/services/web/test/unit/src/UserMembership/UserMembershipController.test.mjs @@ -212,7 +212,7 @@ describe('UserMembershipController', () => { }, }, } - vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.js', () => ({ default: ctx.Modules, })) diff --git a/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs b/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js similarity index 65% rename from services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs rename to services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js index 427d638c34..407510921b 100644 --- a/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs +++ b/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js @@ -1,18 +1,18 @@ -import { expect, vi } from 'vitest' -import sinon from 'sinon' -import HttpPermissionsPolicyMiddleware from '../../../../app/src/infrastructure/HttpPermissionsPolicy.mjs' -import MockRequest from '../helpers/MockRequestVitest.mjs' -import MockResponse from '../helpers/MockResponseVitest.mjs' -const modulePath = - '../../../../app/src/infrastructure/HttpPermissionsPolicy.mjs' +const { expect } = require('chai') +const sinon = require('sinon') +const modulePath = '../../../../app/src/infrastructure/HttpPermissionsPolicy.js' +const SandboxedModule = require('sandboxed-module') +const HttpPermissionsPolicyMiddleware = require('../../../../app/src/infrastructure/HttpPermissionsPolicy') +const MockRequest = require('../helpers/MockRequest') +const MockResponse = require('../helpers/MockResponse') describe('HttpPermissionsPolicy', function () { - beforeEach(async function (ctx) { - ctx.next = sinon.stub() - ctx.HttpPermissionsPolicy = (await import(modulePath)).default - ctx.path = '/foo/bar' - ctx.req = new MockRequest(vi) - ctx.res = new MockResponse(vi) + this.beforeEach(function () { + this.next = sinon.stub() + this.HttpPermissionsPolicy = SandboxedModule.require(modulePath, {}) + this.path = '/foo/bar' + this.req = new MockRequest() + return (this.res = new MockResponse()) }) describe('when a single blocked policy element is provided', function () { @@ -23,7 +23,9 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - expect(httpPermissionsMiddleware.policy).to.equal('accelerometer=()') + return expect(httpPermissionsMiddleware.policy).to.equal( + 'accelerometer=()' + ) }) }) @@ -35,7 +37,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') + return expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') }) }) @@ -48,7 +50,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - expect(httpPermissionsMiddleware.policy).to.equal( + return expect(httpPermissionsMiddleware.policy).to.equal( 'usb=(), hid=(), camera=(self https://example.com), fullscreen=(self)' ) }) @@ -60,7 +62,7 @@ describe('HttpPermissionsPolicy', function () { blocked: ['usb'], allowed: { usb: 'self' }, } - expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( + return expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( 'Invalid Permissions-Policy header configuration' ) }) @@ -72,7 +74,7 @@ describe('HttpPermissionsPolicy', function () { blocked: ['usb'], allowed: { camera: '' }, } - expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( + return expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( 'Invalid Permissions-Policy header configuration' ) }) @@ -87,7 +89,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') + return expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') }) }) @@ -100,7 +102,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - expect(httpPermissionsMiddleware.policy).to.equal('usb=()') + return expect(httpPermissionsMiddleware.policy).to.equal('usb=()') }) }) }) diff --git a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js new file mode 100644 index 0000000000..a5ec96cca7 --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js @@ -0,0 +1,58 @@ +/* eslint-disable + max-len, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +const sinon = require('sinon') +const assert = require('assert') +const path = require('path') +const modulePath = path.join( + __dirname, + '../../../../../app/src/infrastructure/LockManager.js' +) +const lockKey = `lock:web:{${5678}}` +const lockValue = '123456' +const SandboxedModule = require('sandboxed-module') + +describe('LockManager - releasing the lock', function () { + const deleteStub = sinon.stub().callsArgWith(4) + const mocks = { + '@overleaf/settings': { + redis: {}, + lockManager: { + lockTestInterval: 50, + maxTestInterval: 1000, + maxLockWaitTime: 10000, + redisLockExpiry: 30, + slowExecutionThreshold: 5000, + }, + }, + '@overleaf/metrics': {}, + './RedisWrapper': { + client() { + return { + auth() {}, + eval: deleteStub, + } + }, + }, + } + + const LockManager = SandboxedModule.require(modulePath, { requires: mocks }) + LockManager.unlockScript = 'this is the unlock script' + + it('should put a all data into memory', function (done) { + return LockManager._releaseLock(lockKey, lockValue, () => { + deleteStub + .calledWith(LockManager.unlockScript, 1, lockKey, lockValue) + .should.equal(true) + return done() + }) + }) +}) diff --git a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.test.mjs b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.test.mjs deleted file mode 100644 index 7607e74b4b..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.test.mjs +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-disable - max-len, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -import sinon from 'sinon' -import path from 'node:path' -import { vi } from 'vitest' -const modulePath = path.join( - import.meta.dirname, - '../../../../../app/src/infrastructure/LockManager.mjs' -) -const lockKey = `lock:web:{${5678}}` -const lockValue = '123456' - -describe('LockManager - releasing the lock', function () { - let LockManager - const deleteStub = sinon.stub().callsArgWith(4) - beforeEach(async function () { - vi.doMock('@overleaf/settings', () => ({ - default: { - redis: {}, - lockManager: { - lockTestInterval: 50, - maxTestInterval: 1000, - maxLockWaitTime: 10000, - redisLockExpiry: 30, - slowExecutionThreshold: 5000, - }, - }, - })) - vi.doMock('@overleaf/metrics', () => ({})) - vi.doMock('../../../../../app/src/infrastructure/RedisWrapper', () => ({ - default: { - client() { - return { - auth() {}, - eval: deleteStub, - } - }, - }, - })) - - LockManager = (await import(modulePath)).default - LockManager.unlockScript = 'this is the unlock script' - }) - - it('should put all data into memory', async function () { - await new Promise(resolve => { - return LockManager._releaseLock(lockKey, lockValue, () => { - deleteStub - .calledWith(LockManager.unlockScript, 1, lockKey, lockValue) - .should.equal(true) - return resolve() - }) - }) - }) -}) diff --git a/services/web/test/unit/src/infrastructure/LockManager/getLock.test.mjs b/services/web/test/unit/src/infrastructure/LockManager/getLock.test.mjs deleted file mode 100644 index 0c9b852e6b..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/getLock.test.mjs +++ /dev/null @@ -1,209 +0,0 @@ -import { vi } from 'vitest' -/* eslint-disable - n/handle-callback-err, - max-len, - no-return-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS101: Remove unnecessary use of Array.from - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -import sinon from 'sinon' - -import path from 'node:path' -const modulePath = path.join( - import.meta.dirname, - '../../../../../app/src/infrastructure/LockManager.mjs' -) - -describe('LockManager - getting the lock', function () { - beforeEach(async function (ctx) { - vi.doMock('../../../../../app/src/infrastructure/RedisWrapper', () => ({ - default: { - client() { - return { auth() {} } - }, - }, - })) - - vi.doMock('@overleaf/settings', () => ({ - default: { - redis: {}, - lockManager: { - lockTestInterval: 50, - maxTestInterval: 1000, - maxLockWaitTime: 10000, - redisLockExpiry: 30, - slowExecutionThreshold: 5000, - }, - }, - })) - - vi.doMock('@overleaf/metrics', () => ({ - default: { - inc() {}, - gauge() {}, - }, - })) - - ctx.LockManager = (await import(modulePath)).default - - ctx.callback = sinon.stub() - ctx.key = 'lock:web:lockName:project-id}' - return (ctx.namespace = 'lockName') - }) - - describe('when the lock is not set', function () { - beforeEach(async function (ctx) { - await new Promise(resolve => { - ctx.LockManager._tryLock = sinon.stub().yields(null, true) - return ctx.LockManager._getLock(ctx.key, ctx.namespace, (...args) => { - ctx.callback(...Array.from(args || [])) - return resolve() - }) - }) - }) - - it('should try to get the lock', function (ctx) { - return ctx.LockManager._tryLock - .calledWith(ctx.key, ctx.namespace) - .should.equal(true) - }) - - it('should only need to try once', function (ctx) { - return ctx.LockManager._tryLock.callCount.should.equal(1) - }) - - it('should return the callback', function (ctx) { - return ctx.callback.calledWith(null).should.equal(true) - }) - - it('should clear the lock queue', function (ctx) { - ctx.LockManager._lockQueuesSize().should.equal(0) - }) - }) - - describe('when the lock is initially set', function () { - beforeEach(async function (ctx) { - await new Promise(resolve => { - const startTime = Date.now() - let tries = 0 - ctx.LockManager.LOCK_TEST_INTERVAL = 5 - ctx.LockManager._tryLock = function (key, namespace, callback) { - if (callback == null) { - callback = function () {} - } - if (Date.now() - startTime < 20 || tries < 2) { - tries = tries + 1 - return callback(null, false) - } else { - return callback(null, true) - } - } - sinon.spy(ctx.LockManager, '_tryLock') - - return ctx.LockManager._getLock(ctx.key, ctx.namespace, (...args) => { - ctx.callback(...Array.from(args || [])) - return resolve() - }) - }) - }) - - it('should call tryLock multiple times until free', function (ctx) { - return (ctx.LockManager._tryLock.callCount > 1).should.equal(true) - }) - - it('should return the callback', function (ctx) { - return ctx.callback.calledWith(null).should.equal(true) - }) - - it('should clear the lock queue', function (ctx) { - ctx.LockManager._lockQueuesSize().should.equal(0) - }) - }) - - describe('when the lock times out', function () { - beforeEach(async function (ctx) { - await new Promise(resolve => { - const time = Date.now() - ctx.LockManager.LOCK_TEST_INTERVAL = 1 - ctx.LockManager.MAX_LOCK_WAIT_TIME = 5 - ctx.LockManager._tryLock = sinon.stub().yields(null, false) - return ctx.LockManager._getLock(ctx.key, ctx.namespace, (...args) => { - ctx.callback(...Array.from(args || [])) - return resolve() - }) - }) - }) - - it('should return the callback with an error', function (ctx) { - ctx.callback.should.have.been.calledWith( - sinon.match.instanceOf(Error).and(sinon.match.has('message', 'Timeout')) - ) - }) - }) - - describe('when there are multiple requests for the same lock', function () { - beforeEach(async function (ctx) { - await new Promise(resolve => { - let locked = false - ctx.results = [] - ctx.LockManager.LOCK_TEST_INTERVAL = 1 - ctx.LockManager._tryLock = function (key, namespace, callback) { - if (callback == null) { - callback = function () {} - } - if (locked) { - return callback(null, false) - } else { - locked = true // simulate getting the lock - return callback(null, true) - } - } - // Start ten lock requests in order at 1ms 2ms 3ms... - // with them randomly holding the lock for 0-10ms. - // Use predefined values for the random delay to make the test - // deterministic. - const randomDelays = [5, 4, 1, 8, 6, 8, 3, 4, 2, 4] - let startTime = 0 - return Array.from(randomDelays).map((randomDelay, i) => - ((randomDelay, i) => { - startTime += 1 - return setTimeout(() => { - // changing the next line to the old method of LockManager._getLockByPolling - // should give results in a random order and cause the test to fail. - return ctx.LockManager._getLock( - ctx.key, - ctx.namespace, - (...args) => { - setTimeout( - () => (locked = false), // release the lock after a random amount of time - randomDelay - ) - ctx.results.push(i) - if (ctx.results.length === 10) { - return resolve() - } - } - ) - }, startTime) - })(randomDelay, i) - ) - }) - }) - - it('should process the requests in order', function (ctx) { - return ctx.results.should.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - }) - - it('should clear the lock queue', function (ctx) { - ctx.LockManager._lockQueuesSize().should.equal(0) - }) - }) -}) diff --git a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js new file mode 100644 index 0000000000..07bd6820c9 --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js @@ -0,0 +1,194 @@ +/* eslint-disable + n/handle-callback-err, + max-len, + no-return-assign, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. +/* + * decaffeinate suggestions: + * DS101: Remove unnecessary use of Array.from + * DS102: Remove unnecessary code created because of implicit returns + * DS207: Consider shorter variations of null checks + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +const sinon = require('sinon') +const path = require('path') +const modulePath = path.join( + __dirname, + '../../../../../app/src/infrastructure/LockManager.js' +) +const SandboxedModule = require('sandboxed-module') + +describe('LockManager - getting the lock', function () { + beforeEach(function () { + this.LockManager = SandboxedModule.require(modulePath, { + requires: { + './RedisWrapper': { + client() { + return { auth() {} } + }, + }, + '@overleaf/settings': { + redis: {}, + lockManager: { + lockTestInterval: 50, + maxTestInterval: 1000, + maxLockWaitTime: 10000, + redisLockExpiry: 30, + slowExecutionThreshold: 5000, + }, + }, + '@overleaf/metrics': { + inc() {}, + gauge() {}, + }, + }, + }) + + this.callback = sinon.stub() + this.key = 'lock:web:lockName:project-id}' + return (this.namespace = 'lockName') + }) + + describe('when the lock is not set', function () { + beforeEach(function (done) { + this.LockManager._tryLock = sinon.stub().yields(null, true) + return this.LockManager._getLock(this.key, this.namespace, (...args) => { + this.callback(...Array.from(args || [])) + return done() + }) + }) + + it('should try to get the lock', function () { + return this.LockManager._tryLock + .calledWith(this.key, this.namespace) + .should.equal(true) + }) + + it('should only need to try once', function () { + return this.LockManager._tryLock.callCount.should.equal(1) + }) + + it('should return the callback', function () { + return this.callback.calledWith(null).should.equal(true) + }) + + it('should clear the lock queue', function () { + this.LockManager._lockQueuesSize().should.equal(0) + }) + }) + + describe('when the lock is initially set', function () { + beforeEach(function (done) { + const startTime = Date.now() + let tries = 0 + this.LockManager.LOCK_TEST_INTERVAL = 5 + this.LockManager._tryLock = function (key, namespace, callback) { + if (callback == null) { + callback = function () {} + } + if (Date.now() - startTime < 20 || tries < 2) { + tries = tries + 1 + return callback(null, false) + } else { + return callback(null, true) + } + } + sinon.spy(this.LockManager, '_tryLock') + + return this.LockManager._getLock(this.key, this.namespace, (...args) => { + this.callback(...Array.from(args || [])) + return done() + }) + }) + + it('should call tryLock multiple times until free', function () { + return (this.LockManager._tryLock.callCount > 1).should.equal(true) + }) + + it('should return the callback', function () { + return this.callback.calledWith(null).should.equal(true) + }) + + it('should clear the lock queue', function () { + this.LockManager._lockQueuesSize().should.equal(0) + }) + }) + + describe('when the lock times out', function () { + beforeEach(function (done) { + const time = Date.now() + this.LockManager.LOCK_TEST_INTERVAL = 1 + this.LockManager.MAX_LOCK_WAIT_TIME = 5 + this.LockManager._tryLock = sinon.stub().yields(null, false) + return this.LockManager._getLock(this.key, this.namespace, (...args) => { + this.callback(...Array.from(args || [])) + return done() + }) + }) + + it('should return the callback with an error', function () { + this.callback.should.have.been.calledWith( + sinon.match.instanceOf(Error).and(sinon.match.has('message', 'Timeout')) + ) + }) + }) + + describe('when there are multiple requests for the same lock', function () { + beforeEach(function (done) { + let locked = false + this.results = [] + this.LockManager.LOCK_TEST_INTERVAL = 1 + this.LockManager._tryLock = function (key, namespace, callback) { + if (callback == null) { + callback = function () {} + } + if (locked) { + return callback(null, false) + } else { + locked = true // simulate getting the lock + return callback(null, true) + } + } + // Start ten lock requests in order at 1ms 2ms 3ms... + // with them randomly holding the lock for 0-10ms. + // Use predefined values for the random delay to make the test + // deterministic. + const randomDelays = [5, 4, 1, 8, 6, 8, 3, 4, 2, 4] + let startTime = 0 + return Array.from(randomDelays).map((randomDelay, i) => + ((randomDelay, i) => { + startTime += 1 + return setTimeout(() => { + // changing the next line to the old method of LockManager._getLockByPolling + // should give results in a random order and cause the test to fail. + return this.LockManager._getLock( + this.key, + this.namespace, + (...args) => { + setTimeout( + () => (locked = false), // release the lock after a random amount of time + randomDelay + ) + this.results.push(i) + if (this.results.length === 10) { + return done() + } + } + ) + }, startTime) + })(randomDelay, i) + ) + }) + + it('should process the requests in order', function () { + return this.results.should.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + }) + + it('should clear the lock queue', function () { + this.LockManager._lockQueuesSize().should.equal(0) + }) + }) +}) diff --git a/services/web/test/unit/src/infrastructure/LockManager/tryLock.test.mjs b/services/web/test/unit/src/infrastructure/LockManager/tryLock.test.mjs deleted file mode 100644 index f44d8a555d..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/tryLock.test.mjs +++ /dev/null @@ -1,88 +0,0 @@ -import { vi } from 'vitest' -/* eslint-disable - max-len, - no-return-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -import sinon from 'sinon' - -import path from 'node:path' -const modulePath = path.join( - import.meta.dirname, - '../../../../../app/src/infrastructure/LockManager.mjs' -) - -describe('LockManager - trying the lock', function () { - beforeEach(async function (ctx) { - vi.doMock('../../../../../app/src/infrastructure/RedisWrapper', () => ({ - default: { - client: () => { - return { - auth() {}, - set: (ctx.set = sinon.stub()), - } - }, - }, - })) - - vi.doMock('@overleaf/settings', () => ({ - default: { - redis: {}, - lockManager: { - lockTestInterval: 50, - maxTestInterval: 1000, - maxLockWaitTime: 10000, - redisLockExpiry: 30, - slowExecutionThreshold: 5000, - }, - }, - })) - - vi.doMock('@overleaf/metrics', () => ({ - default: { - inc() {}, - }, - })) - - ctx.LockManager = (await import(modulePath)).default - ctx.callback = sinon.stub() - ctx.key = 'lock:web:lockName:project-id}' - return (ctx.namespace = 'lockName') - }) - - describe('when the lock is not set', function () { - beforeEach(function (ctx) { - ctx.set.callsArgWith(5, null, 'OK') - ctx.LockManager.randomLock = sinon.stub().returns('random-lock-value') - return ctx.LockManager._tryLock(ctx.key, ctx.namespace, ctx.callback) - }) - - it('should set the lock key with an expiry if it is not set', function (ctx) { - return ctx.set - .calledWith(ctx.key, 'random-lock-value', 'EX', 30, 'NX') - .should.equal(true) - }) - - it('should return the callback with true', function (ctx) { - return ctx.callback.calledWith(null, true).should.equal(true) - }) - }) - - describe('when the lock is already set', function () { - beforeEach(function (ctx) { - ctx.set.callsArgWith(5, null, null) - return ctx.LockManager._tryLock(ctx.key, ctx.namespace, ctx.callback) - }) - - it('should return the callback with false', function (ctx) { - return ctx.callback.calledWith(null, false).should.equal(true) - }) - }) -}) diff --git a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js new file mode 100644 index 0000000000..9252797f2f --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js @@ -0,0 +1,81 @@ +/* eslint-disable + max-len, + no-return-assign, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +const sinon = require('sinon') +const path = require('path') +const modulePath = path.join( + __dirname, + '../../../../../app/src/infrastructure/LockManager.js' +) +const SandboxedModule = require('sandboxed-module') + +describe('LockManager - trying the lock', function () { + beforeEach(function () { + this.LockManager = SandboxedModule.require(modulePath, { + requires: { + './RedisWrapper': { + client: () => { + return { + auth() {}, + set: (this.set = sinon.stub()), + } + }, + }, + '@overleaf/settings': { + redis: {}, + lockManager: { + lockTestInterval: 50, + maxTestInterval: 1000, + maxLockWaitTime: 10000, + redisLockExpiry: 30, + slowExecutionThreshold: 5000, + }, + }, + '@overleaf/metrics': { + inc() {}, + }, + }, + }) + this.callback = sinon.stub() + this.key = 'lock:web:lockName:project-id}' + return (this.namespace = 'lockName') + }) + + describe('when the lock is not set', function () { + beforeEach(function () { + this.set.callsArgWith(5, null, 'OK') + this.LockManager.randomLock = sinon.stub().returns('random-lock-value') + return this.LockManager._tryLock(this.key, this.namespace, this.callback) + }) + + it('should set the lock key with an expiry if it is not set', function () { + return this.set + .calledWith(this.key, 'random-lock-value', 'EX', 30, 'NX') + .should.equal(true) + }) + + it('should return the callback with true', function () { + return this.callback.calledWith(null, true).should.equal(true) + }) + }) + + describe('when the lock is already set', function () { + beforeEach(function () { + this.set.callsArgWith(5, null, null) + return this.LockManager._tryLock(this.key, this.namespace, this.callback) + }) + + it('should return the callback with false', function () { + return this.callback.calledWith(null, false).should.equal(true) + }) + }) +}) diff --git a/services/web/test/unit/src/infrastructure/RateLimiter.test.mjs b/services/web/test/unit/src/infrastructure/RateLimiter.test.mjs deleted file mode 100644 index bb2fccaf68..0000000000 --- a/services/web/test/unit/src/infrastructure/RateLimiter.test.mjs +++ /dev/null @@ -1,95 +0,0 @@ -import { vi, expect } from 'vitest' -import sinon from 'sinon' -const modulePath = '../../../../app/src/infrastructure/RateLimiter' - -describe('RateLimiter', function () { - beforeEach(async function (ctx) { - ctx.rclient = {} - ctx.RedisWrapper = { - client: sinon.stub().returns(ctx.rclient), - } - ctx.RateLimiter = { - RateLimiter: sinon.stub().withArgs('login').returns(ctx.rateLimiter), - } - - ctx.RateLimiterFlexible = { - RateLimiterRedis: sinon.stub(), - } - ctx.Settings = {} - - vi.doMock('../../../../app/src/infrastructure/RedisWrapper', () => ({ - default: ctx.RedisWrapper, - })) - - vi.doMock('rate-limiter-flexible', () => ({ - default: ctx.RateLimiterFlexible, - })) - - vi.doMock('@overleaf/settings', () => ({ - default: ctx.Settings, - })) - - ctx.RateLimiter = (await import(modulePath)).default - }) - - describe('getSubnetKeyFromIp', function () { - beforeEach(function (ctx) { - ctx.rateLimiter = new ctx.RateLimiter.RateLimiter('some-limit', { - points: 20, - subnetPoints: 200, - duration: 60, - }) - }) - - it('should correctly extract a subnet key from an ip address', function (ctx) { - expect(ctx.rateLimiter.getSubnetKeyFromIp('255.255.255.255')).to.equal( - '255.255.255' - ) - expect(ctx.rateLimiter.getSubnetKeyFromIp('127.0.0.1')).to.equal( - '127.0.0' - ) - expect(ctx.rateLimiter.getSubnetKeyFromIp('243.12.3.126')).to.equal( - '243.12.3' - ) - }) - - it('should throw an error when given an incorrectly formatted ip', function (ctx) { - expect(() => ctx.rateLimiter.getSubnetKeyFromIp(1)).to.throw() - expect(() => ctx.rateLimiter.getSubnetKeyFromIp('Not an ip')).to.throw() - expect(() => - ctx.rateLimiter.getSubnetKeyFromIp('255.255.255.255.255.255') - ).to.throw() - expect(() => ctx.rateLimiter.getSubnetKeyFromIp('255.255.255')).to.throw() - }) - }) - - describe('_subnetRateLimiter', function () { - it('should be defined by default', function (ctx) { - const rateLimiter = new ctx.RateLimiter.RateLimiter('some-limit', { - points: 20, - subnetPoints: 200, - duration: 60, - }) - expect(rateLimiter._subnetRateLimiter).not.to.be.undefined - }) - - it('should be undefined when subnet rate limiting is disabled', function (ctx) { - ctx.Settings.rateLimit = { subnetRateLimiterDisabled: true } - - const rateLimiter = new ctx.RateLimiter.RateLimiter('some-limit', { - points: 20, - subnetPoints: 200, - duration: 60, - }) - expect(rateLimiter._subnetRateLimiter).to.be.undefined - }) - - it('should be undefined when subnetPoints are not passed as an option', function (ctx) { - const rateLimiter = new ctx.RateLimiter.RateLimiter('some-limit', { - points: 20, - duration: 60, - }) - expect(rateLimiter._subnetRateLimiter).to.be.undefined - }) - }) -}) diff --git a/services/web/test/unit/src/infrastructure/RateLimiterTests.js b/services/web/test/unit/src/infrastructure/RateLimiterTests.js new file mode 100644 index 0000000000..4d0b2c2f98 --- /dev/null +++ b/services/web/test/unit/src/infrastructure/RateLimiterTests.js @@ -0,0 +1,95 @@ +const SandboxedModule = require('sandboxed-module') +const sinon = require('sinon') +const { expect } = require('chai') +const modulePath = require('path').join( + __dirname, + '../../../../app/src/infrastructure/RateLimiter' +) + +describe('RateLimiter', function () { + beforeEach(function () { + this.rclient = {} + this.RedisWrapper = { + client: sinon.stub().returns(this.rclient), + } + this.RateLimiter = { + RateLimiter: sinon.stub().withArgs('login').returns(this.rateLimiter), + } + + this.RateLimiterFlexible = { + RateLimiterRedis: sinon.stub(), + } + this.Settings = {} + + this.RateLimiter = SandboxedModule.require(modulePath, { + requires: { + './RedisWrapper': this.RedisWrapper, + 'rate-limiter-flexible': this.RateLimiterFlexible, + '@overleaf/settings': this.Settings, + }, + }) + }) + + describe('getSubnetKeyFromIp', function () { + beforeEach(function () { + this.rateLimiter = new this.RateLimiter.RateLimiter('some-limit', { + points: 20, + subnetPoints: 200, + duration: 60, + }) + }) + + it('should correctly extract a subnet key from an ip address', function () { + expect(this.rateLimiter.getSubnetKeyFromIp('255.255.255.255')).to.equal( + '255.255.255' + ) + expect(this.rateLimiter.getSubnetKeyFromIp('127.0.0.1')).to.equal( + '127.0.0' + ) + expect(this.rateLimiter.getSubnetKeyFromIp('243.12.3.126')).to.equal( + '243.12.3' + ) + }) + + it('should throw an error when given an incorrectly formatted ip', function () { + expect(() => this.rateLimiter.getSubnetKeyFromIp(1)).to.throw() + expect(() => this.rateLimiter.getSubnetKeyFromIp('Not an ip')).to.throw() + expect(() => + this.rateLimiter.getSubnetKeyFromIp('255.255.255.255.255.255') + ).to.throw() + expect(() => + this.rateLimiter.getSubnetKeyFromIp('255.255.255') + ).to.throw() + }) + }) + + describe('_subnetRateLimiter', function () { + it('should be defined by default', function () { + const rateLimiter = new this.RateLimiter.RateLimiter('some-limit', { + points: 20, + subnetPoints: 200, + duration: 60, + }) + expect(rateLimiter._subnetRateLimiter).not.to.be.undefined + }) + + it('should be undefined when subnet rate limiting is disabled', function () { + this.Settings.rateLimit = { subnetRateLimiterDisabled: true } + + const rateLimiter = new this.RateLimiter.RateLimiter('some-limit', { + points: 20, + subnetPoints: 200, + duration: 60, + }) + expect(rateLimiter._subnetRateLimiter).to.be.undefined + }) + + it('should be undefined when subnetPoints are not passed as an option', function () { + const rateLimiter = new this.RateLimiter.RateLimiter('some-limit', { + points: 20, + duration: 60, + }) + expect(rateLimiter._subnetRateLimiter).to.be.undefined + }) + }) +}) diff --git a/services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs b/services/web/test/unit/src/infrastructure/RequestContentTypeDetectionTests.js similarity index 52% rename from services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs rename to services/web/test/unit/src/infrastructure/RequestContentTypeDetectionTests.js index 2d0ae588c4..b214a71f56 100644 --- a/services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs +++ b/services/web/test/unit/src/infrastructure/RequestContentTypeDetectionTests.js @@ -1,23 +1,24 @@ -import accepts from 'accepts' -import { expect, vi } from 'vitest' -import MockRequest from '../helpers/MockRequestVitest.mjs' +const accepts = require('accepts') +const { expect } = require('chai') const MODULE_PATH = - '../../../../app/src/infrastructure/RequestContentTypeDetection.mjs' + '../../../../app/src/infrastructure/RequestContentTypeDetection.js' +const MockRequest = require('../helpers/MockRequest') +const SandboxedModule = require('sandboxed-module') describe('RequestContentTypeDetection', function () { - beforeEach(async function (ctx) { - ctx.RequestContentTypeDetection = await import(MODULE_PATH) - ctx.req = new MockRequest(vi) - ctx.req.accepts = function (...args) { + before(function () { + this.RequestContentTypeDetection = SandboxedModule.require(MODULE_PATH) + this.req = new MockRequest() + this.req.accepts = function (...args) { return accepts(this).type(...args) } }) describe('isJson=true', function () { function expectJson(type) { - it(type, function (ctx) { - ctx.req.headers.accept = type - expect(ctx.RequestContentTypeDetection.acceptsJson(ctx.req)).to.equal( + it(type, function () { + this.req.headers.accept = type + expect(this.RequestContentTypeDetection.acceptsJson(this.req)).to.equal( true ) }) @@ -30,9 +31,9 @@ describe('RequestContentTypeDetection', function () { describe('isJson=false', function () { function expectNonJson(type) { - it(type, function (ctx) { - ctx.req.headers.accept = type - expect(ctx.RequestContentTypeDetection.acceptsJson(ctx.req)).to.equal( + it(type, function () { + this.req.headers.accept = type + expect(this.RequestContentTypeDetection.acceptsJson(this.req)).to.equal( false ) }) diff --git a/services/web/test/unit/src/infrastructure/Views.test.mjs b/services/web/test/unit/src/infrastructure/Views.js similarity index 78% rename from services/web/test/unit/src/infrastructure/Views.test.mjs rename to services/web/test/unit/src/infrastructure/Views.js index cef6db5f36..7b601f5d9c 100644 --- a/services/web/test/unit/src/infrastructure/Views.test.mjs +++ b/services/web/test/unit/src/infrastructure/Views.js @@ -1,19 +1,21 @@ -import { vi, expect } from 'vitest' +/* eslint-disable no-template-curly-in-string */ -import pug from 'pug' -const modulePath = '../../../../app/src/infrastructure/Views.mjs' +const { expect } = require('chai') +const pug = require('pug') +const modulePath = '../../../../app/src/infrastructure/Views.js' +const SandboxedModule = require('sandboxed-module') describe('Views', function () { - beforeEach(async function (ctx) { - vi.doMock('@overleaf/settings', () => ({ - default: (ctx.settings = { - viewIncludes: { - someInclude: 'path/to/_include.pug', - }, - }), - })) - - ctx.Views = (await import(modulePath)).default + beforeEach(function () { + this.Views = SandboxedModule.require(modulePath, { + requires: { + '@overleaf/settings': (this.settings = { + viewIncludes: { + someInclude: 'path/to/_include.pug', + }, + }), + }, + }) }) describe('_expectMetaFor', function () { @@ -50,8 +52,8 @@ describe('Views', function () { }, ] for (const { name, filename, firstLine, expectMeta } of cases) { - it(name, function (ctx) { - expect(ctx.Views._expectMetaFor(filename, firstLine)).to.equal( + it(name, function () { + expect(this.Views._expectMetaFor(filename, firstLine)).to.equal( expectMeta ) }) @@ -98,9 +100,7 @@ describe('Views', function () { }, { name: 'computed code', - // eslint-disable-next-line no-template-curly-in-string src: 'meta(name=`ol-prefix-${foo}` content=1)', - // eslint-disable-next-line no-template-curly-in-string found: ['ol-prefix-${foo}'], duplicates: [], }, @@ -118,9 +118,9 @@ describe('Views', function () { }, ] for (const { name, compiled, src, found, duplicates } of cases) { - it(name, function (ctx) { - const res = ctx.Views._findAllMetaTags( - compiled || pug.compileClient(src, ctx.Views.PUG_COMPILE_ARGUMENTS) + it(name, function () { + const res = this.Views._findAllMetaTags( + compiled || pug.compileClient(src, this.Views.PUG_COMPILE_ARGUMENTS) ) expect(res).to.deep.equal({ found, duplicates }) })