diff --git a/services/web/app.mjs b/services/web/app.mjs index 5de7ee17e2..9103dc3d4e 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.js' +import Modules from './app/src/infrastructure/Modules.mjs' 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.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 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 { 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 014934905c..c3a2c4e09c 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.js' +import Metrics from '../../infrastructure/Metrics.mjs' 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 161efcfcca..f19df459cb 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 7f6187dfc2..73af8d5058 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.js' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' import AdminAuthorizationHelper from '../Helpers/AdminAuthorizationHelper.mjs' -import Modules from '../../infrastructure/Modules.js' +import Modules from '../../infrastructure/Modules.mjs' 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 ab24e0e41e..e49c5be410 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.js' +import { db, ObjectId } from '../../infrastructure/mongodb.mjs' 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 9dd6bf6300..29b3ef4ae2 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 5924750f9e..f35d8c4469 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.js' +import Modules from '../../infrastructure/Modules.mjs' const { ForbiddenError } = Errors diff --git a/services/web/app/src/Features/Chat/ChatController.mjs b/services/web/app/src/Features/Chat/ChatController.mjs index 569fa56597..3cbd7e0132 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 b70553218e..cf31f5804e 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.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 aca557934a..06e4e3a55e 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.js' -import { z, zz, validateReq } from '../../infrastructure/Validation.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 394cae6453..6b4ead8cac 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 cc21fcd09a..7ccb1c9ba3 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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 f1a3a6e8fc..c4ba3050a8 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.js' -import Validation from '../../infrastructure/Validation.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import Validation from '../../infrastructure/Validation.mjs' 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 c951326fc4..e1629f4871 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 7b02318d91..5673d0be2d 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 5f190d1a08..0d7eb28f29 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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 bd35f93b4d..4de5446a31 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.js' +import { plainTextResponse } from '../../infrastructure/Response.mjs' 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 cf9b36de75..c9cc737b46 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 399240d53a..764c2efbca 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.js' +import { plainTextResponse } from '../../infrastructure/Response.mjs' import { expressify } from '@overleaf/promise-utils' -import Modules from '../../infrastructure/Modules.js' +import Modules from '../../infrastructure/Modules.mjs' 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 42dcffcd4f..adea09f9a6 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.js' +import { prepareZipAttachment } from '../../infrastructure/Response.mjs' let ProjectDownloadsController diff --git a/services/web/app/src/Features/Editor/EditorHttpController.mjs b/services/web/app/src/Features/Editor/EditorHttpController.mjs index 9fe2550e4e..aefe529e05 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.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 4574e3deda..46b80302df 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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 908fef0ab7..09833221a4 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 da32ebee8f..c960a4949a 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 25b297eb0e..bc95b90128 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.js' +import { plainTextResponse } from '../../infrastructure/Response.mjs' 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 5f8b348310..07745dd3bb 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.js' +import { plainTextResponse } from '../../infrastructure/Response.mjs' 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 252485cf49..0d1ea402d1 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.js' +import { preparePlainTextResponse } from '../../infrastructure/Response.mjs' 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 6abc6602b9..51612969f7 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 238efa2f1e..853da549b6 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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 6a7fde9d79..0e10abb04f 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 3365c22646..c74a9c24da 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.js' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' export default { redirect, diff --git a/services/web/app/src/Features/History/HistoryController.mjs b/services/web/app/src/Features/History/HistoryController.mjs index d78ab0cb1a..e0cf991bdf 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.js' +import { prepareZipAttachment } from '../../infrastructure/Response.mjs' import Features from '../../infrastructure/Features.mjs' -import { z, zz, validateReq } from '../../infrastructure/Validation.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' // 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 ccb17fd277..9e77d95d9a 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.js' +import { db, waitForDb } from '../../infrastructure/mongodb.mjs' 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 76dcdb17a5..b57ff81fc3 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.js' +import mongodb from '../../infrastructure/mongodb.mjs' 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 f1e1f187b2..abf43eb486 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 c758b97c5b..dfa2118453 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.js' -import Metrics from '../../infrastructure/Metrics.js' +import FileWriter from '../../infrastructure/FileWriter.mjs' +import Metrics from '../../infrastructure/Metrics.mjs' 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 be91231fd3..53f9f569e5 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.js' -import { READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.js' +import Modules from '../../infrastructure/Modules.mjs' +import { READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.mjs' 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 8400cdfa83..dbf25a77f3 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 f60be663da..696cbc7db5 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.js' -import { plainTextResponse } from '../../infrastructure/Response.js' -import { z, zz, validateReq } from '../../infrastructure/Validation.js' +import Modules from '../../infrastructure/Modules.mjs' +import { plainTextResponse } from '../../infrastructure/Response.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 4bbc9069b8..f9c9bf81bb 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.js' +import FileWriter from '../../infrastructure/FileWriter.mjs' 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 fa1a5ccb40..735c3f1041 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 a945c93ffd..a4182e50d5 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.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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 cfd8e2f871..5df869bc0b 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 064ebff3a3..30f1ec19e6 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.js' -import { z, zz, validateReq } from '../../infrastructure/Validation.js' +import Modules from '../../infrastructure/Modules.mjs' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 eda7671270..cf8f035516 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.js' -import Modules from '../../infrastructure/Modules.js' +} from '../../infrastructure/mongodb.mjs' +import Modules from '../../infrastructure/Modules.mjs' 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 d125578651..c189db966f 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 59e0d72619..d526fa5202 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.js' +import LockManager from '../../infrastructure/LockManager.mjs' 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 34d76d893c..9d243a555c 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.js' +import LockManager from '../../infrastructure/LockManager.mjs' 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.js' +import FileWriter from '../../infrastructure/FileWriter.mjs' 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 77069a7d72..a44e93645e 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.js' +import { db } from '../../infrastructure/mongodb.mjs' import Mongo from '../Helpers/Mongo.mjs' import OError from '@overleaf/o-error' import { Project } from '../../models/Project.mjs' -import LockManager from '../../infrastructure/LockManager.js' +import LockManager from '../../infrastructure/LockManager.mjs' 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 2acbb85c66..c1f418406d 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 d80e8c75c8..b73cc8da42 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.js' +import { db, ObjectId } from '../../infrastructure/mongodb.mjs' 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 3fff847fd1..a640bf7927 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.js' +import { BackgroundTaskTracker } from '../../infrastructure/GracefulShutdown.mjs' 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 f85f9be5f7..505d6b3b6a 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 2bfb7844e3..ba6b7147f6 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.js' +import { db } from '../../infrastructure/mongodb.mjs' 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 0ab66029b1..c42520570d 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 aae59aa51b..dc2d78fcb0 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.js' +import mongodb from '../../infrastructure/mongodb.mjs' 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 1447de1e92..2e55ad5691 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.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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 c4bd3d7ee6..13a5ae9b61 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 a1943ae8ef..02038a3a51 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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 746274c161..208c12f72f 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.js' +import Modules from '../../infrastructure/Modules.mjs' import UserGetter from '../User/UserGetter.mjs' import { Subscription } from '../../models/Subscription.mjs' -import { z, validateReq } from '../../infrastructure/Validation.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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 facdf16a13..ff584fee1c 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 0aed675c84..19f9f658c4 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.js' +import Modules from '../../infrastructure/Modules.mjs' import SplitTestHandler from '../SplitTests/SplitTestHandler.mjs' import { AI_ADD_ON_CODE } from './AiHelper.mjs' diff --git a/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs b/services/web/app/src/Features/Subscription/SubscriptionRouter.mjs index 36e2d201b9..9abbd823e0 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 f0a0ef7ec2..a6ae37103b 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.js' +import { db, ObjectId } from '../../infrastructure/mongodb.mjs' 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.js' -import Modules from '../../infrastructure/Modules.js' +import mongoose from '../../infrastructure/Mongoose.mjs' +import Modules from '../../infrastructure/Modules.mjs' /** * @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 b573a4fad3..422628f0eb 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 76f8a222dc..c4dee9970a 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.js' -import Modules from '../../infrastructure/Modules.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' +import Modules from '../../infrastructure/Modules.mjs' 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 53d5237e7b..bcc85abeff 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 a664a56fba..7561917ef0 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.js' +import { addRequiredCleanupHandlerBeforeDrainingConnections } from '../../infrastructure/GracefulShutdown.mjs' 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 c8ac8fca6f..873f7ea0e5 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.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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 b44491dc00..4579b04412 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 1149ba9939..57e1a7e0fc 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 4cd3e90778..d00c851dad 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' 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 dbfa58d5a9..f9c1e6dad1 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.js' +import { z, validateReq } from '../../infrastructure/Validation.mjs' 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.js' -import Modules from '../../infrastructure/Modules.js' +import { acceptsJson } from '../../infrastructure/RequestContentTypeDetection.mjs' +import Modules from '../../infrastructure/Modules.mjs' 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 ee220304b6..79eafa10df 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 008bc62030..cf9e8adf74 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' import Features from '../../infrastructure/Features.mjs' import tsscmp from 'tsscmp' -import Modules from '../../infrastructure/Modules.js' +import Modules from '../../infrastructure/Modules.mjs' 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 c2459c35dc..71b7312746 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.js' +import { db } from '../../infrastructure/mongodb.mjs' 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.js' +import Modules from '../../infrastructure/Modules.mjs' import FeaturesHelper from '../Subscription/FeaturesHelper.mjs' -import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.js' +import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.mjs' 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 1a670dbc83..e9da67f7b9 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.js' +import { db, READ_PREFERENCE_SECONDARY } from '../../infrastructure/mongodb.mjs' 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 42d7167b9d..b4c72fd82f 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 ff41eb6b15..2e7fe27283 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.js' +import RedisWrapper from '../../infrastructure/RedisWrapper.mjs' 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 4f4cdf2ba7..d27aff6ffe 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.js' +import { db } from '../../infrastructure/mongodb.mjs' 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.js' +import Modules from '../../infrastructure/Modules.mjs' import UserSessionsManager from './UserSessionsManager.mjs' import ThirdPartyIdentityManager from './ThirdPartyIdentityManager.mjs' -import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.js' +import AsyncLocalStorage from '../../infrastructure/AsyncLocalStorage.mjs' const { normalizeQuery } = Mongo diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs index 381299d910..d0194dd0bb 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.js' +import { csvAttachment } from '../../infrastructure/Response.mjs' 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.js' +import Modules from '../../infrastructure/Modules.mjs' 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 1eac2e6c1d..13289c0096 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.js' +import { z, zz, validateReq } from '../../infrastructure/Validation.mjs' 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 ecdd7571e5..36d02b4818 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.js' +import { RateLimiter } from '../../infrastructure/RateLimiter.mjs' import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.mjs' const rateLimiters = { diff --git a/services/web/app/src/infrastructure/AsyncLocalStorage.js b/services/web/app/src/infrastructure/AsyncLocalStorage.mjs similarity index 90% rename from services/web/app/src/infrastructure/AsyncLocalStorage.js rename to services/web/app/src/infrastructure/AsyncLocalStorage.mjs index 11461b57b1..eb822e6b9e 100644 --- a/services/web/app/src/infrastructure/AsyncLocalStorage.js +++ b/services/web/app/src/infrastructure/AsyncLocalStorage.mjs @@ -1,5 +1,5 @@ // @ts-check -const { AsyncLocalStorage } = require('node:async_hooks') +import { AsyncLocalStorage } from 'node:async_hooks' /** * @typedef {Object} RequestContext @@ -31,7 +31,7 @@ function removeItem(key) { } } -module.exports = { +export default { middleware, storage: asyncLocalStorage, removeItem, diff --git a/services/web/app/src/infrastructure/ExpressLocals.mjs b/services/web/app/src/infrastructure/ExpressLocals.mjs index b7c32faed4..a49e218d91 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.js' +import Modules from './Modules.mjs' import Errors from '../Features/Errors/Errors.js' import AdminAuthorizationHelper from '../Features/Helpers/AdminAuthorizationHelper.mjs' -import { addOptionalCleanupHandlerAfterDrainingConnections } from './GracefulShutdown.js' +import { addOptionalCleanupHandlerAfterDrainingConnections } from './GracefulShutdown.mjs' import { sanitizeSessionUserForFrontEnd } from './FrontEndUser.mjs' import { expressify } from '@overleaf/promise-utils' diff --git a/services/web/app/src/infrastructure/FileWriter.js b/services/web/app/src/infrastructure/FileWriter.mjs similarity index 88% rename from services/web/app/src/infrastructure/FileWriter.js rename to services/web/app/src/infrastructure/FileWriter.mjs index 1a56f5fa26..12cf89fdd7 100644 --- a/services/web/app/src/infrastructure/FileWriter.js +++ b/services/web/app/src/infrastructure/FileWriter.mjs @@ -5,18 +5,19 @@ * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -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 fs from 'node:fs' -class SizeLimitedStream extends Transform { +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 { constructor(options) { options.autoDestroy = true super(options) @@ -179,8 +180,8 @@ const FileWriter = { }, } -module.exports = FileWriter -module.exports.promises = promisifyAll(FileWriter, { +FileWriter.promises = promisifyAll(FileWriter, { without: ['ensureDumpFolderExists'], }) -module.exports.SizeLimitedStream = SizeLimitedStream + +export default FileWriter diff --git a/services/web/app/src/infrastructure/GracefulShutdown.js b/services/web/app/src/infrastructure/GracefulShutdown.mjs similarity index 84% rename from services/web/app/src/infrastructure/GracefulShutdown.js rename to services/web/app/src/infrastructure/GracefulShutdown.mjs index 515f8b1e7e..c2fba67105 100644 --- a/services/web/app/src/infrastructure/GracefulShutdown.js +++ b/services/web/app/src/infrastructure/GracefulShutdown.mjs @@ -9,29 +9,37 @@ - By now the node app should exit on its own. */ -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) +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 optionalCleanupHandlersBeforeStoppingTraffic = [] const requiredCleanupHandlersBeforeDrainingConnections = [] const optionalCleanupHandlersAfterDrainingConnections = [] const connectionDrainer = [] -function addConnectionDrainer(label, handler) { +export function addConnectionDrainer(label, handler) { connectionDrainer.push({ label, handler }) } -function addOptionalCleanupHandlerBeforeStoppingTraffic(label, handler) { +export function addOptionalCleanupHandlerBeforeStoppingTraffic(label, handler) { optionalCleanupHandlersBeforeStoppingTraffic.push({ label, handler }) } -function addRequiredCleanupHandlerBeforeDrainingConnections(label, handler) { +export function addRequiredCleanupHandlerBeforeDrainingConnections( + label, + handler +) { requiredCleanupHandlersBeforeDrainingConnections.push({ label, handler }) } -function addOptionalCleanupHandlerAfterDrainingConnections(label, handler) { +export function addOptionalCleanupHandlerAfterDrainingConnections( + label, + handler +) { optionalCleanupHandlersAfterDrainingConnections.push({ label, handler }) } @@ -55,7 +63,7 @@ async function runHandlers(stage, handlers, logOnly) { * @param {import('net').Server} [server] * @param {number|string} [signal] */ -async function gracefulShutdown(server, signal) { +export async function gracefulShutdown(server, signal) { logger.warn({ signal }, 'graceful shutdown: started shutdown sequence') Settings.shuttingDown = true @@ -110,7 +118,7 @@ async function gracefulShutdown(server, signal) { logger.info({}, 'graceful shutdown: ready to exit') } -function triggerGracefulShutdown(server, signal) { +export function triggerGracefulShutdown(server, signal) { gracefulShutdown(server, signal).catch(err => { logger.err( { err }, @@ -119,7 +127,7 @@ function triggerGracefulShutdown(server, signal) { }) } -class BackgroundTaskTracker { +export 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 @@ -141,7 +149,7 @@ class BackgroundTaskTracker { } } -module.exports = { +export default { BackgroundTaskTracker, addConnectionDrainer, addOptionalCleanupHandlerBeforeStoppingTraffic, diff --git a/services/web/app/src/infrastructure/HttpPermissionsPolicy.js b/services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs similarity index 95% rename from services/web/app/src/infrastructure/HttpPermissionsPolicy.js rename to services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs index 2c81ddb868..7491871da2 100644 --- a/services/web/app/src/infrastructure/HttpPermissionsPolicy.js +++ b/services/web/app/src/infrastructure/HttpPermissionsPolicy.mjs @@ -1,6 +1,6 @@ // @ts-check -const Settings = require('@overleaf/settings') +import Settings from '@overleaf/settings' /** * @import { HttpPermissionsPolicy } from './types' @@ -85,4 +85,4 @@ class HttpPermissionsPolicyMiddleware { } } -module.exports = HttpPermissionsPolicyMiddleware +export default HttpPermissionsPolicyMiddleware diff --git a/services/web/app/src/infrastructure/LockManager.js b/services/web/app/src/infrastructure/LockManager.mjs similarity index 81% rename from services/web/app/src/infrastructure/LockManager.js rename to services/web/app/src/infrastructure/LockManager.mjs index 8c21409a28..077ed66cab 100644 --- a/services/web/app/src/infrastructure/LockManager.js +++ b/services/web/app/src/infrastructure/LockManager.mjs @@ -1,9 +1,8 @@ -const settings = require('@overleaf/settings') -const RedisWrapper = require('./RedisWrapper') +import settings from '@overleaf/settings' +import RedisWrapper from './RedisWrapper.mjs' +import RedisWebLocker from '@overleaf/redis-wrapper/RedisWebLocker.js' 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({ @@ -33,4 +32,4 @@ LockManager.withTimeout = function (timeout) { return createLockManager(lockManagerSettingsWithTimeout) } -module.exports = LockManager +export default LockManager diff --git a/services/web/app/src/infrastructure/Metrics.js b/services/web/app/src/infrastructure/Metrics.mjs similarity index 60% rename from services/web/app/src/infrastructure/Metrics.js rename to services/web/app/src/infrastructure/Metrics.mjs index b0fbf7aabd..31374badcc 100644 --- a/services/web/app/src/infrastructure/Metrics.js +++ b/services/web/app/src/infrastructure/Metrics.mjs @@ -1,22 +1,28 @@ // @ts-check -const Metrics = require('@overleaf/metrics') +import Metrics from '@overleaf/metrics' -exports.analyticsQueue = new Metrics.prom.Counter({ +const analyticsQueue = new Metrics.prom.Counter({ name: 'analytics_queue', help: 'Number of events sent to the analytics queue', labelNames: ['status', 'event_type'], }) -exports.revertFileDurationSeconds = new Metrics.prom.Histogram({ +const 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'], }) -exports.revertProjectDurationSeconds = new Metrics.prom.Histogram({ +const 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.js b/services/web/app/src/infrastructure/Modules.mjs similarity index 94% rename from services/web/app/src/infrastructure/Modules.js rename to services/web/app/src/infrastructure/Modules.mjs index aea3aeb087..4d35491651 100644 --- a/services/web/app/src/infrastructure/Modules.js +++ b/services/web/app/src/infrastructure/Modules.mjs @@ -1,17 +1,18 @@ // @ts-check -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 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' /** @import { WebModule } from "../../../types/web-module" */ /** @import { RequestHandler } from "express" */ -const MODULE_BASE_PATH = Path.join(__dirname, '/../../../modules') +const MODULE_BASE_PATH = Path.join(import.meta.dirname, '/../../../modules') /** @type {WebModule[]} */ const _modules = [] @@ -207,7 +208,7 @@ async function getMiddleware(name) { return _middleware[name] || [] } -module.exports = { +export default { applyNonCsrfRouter, applyRouter, linkedFileAgentsIncludes, diff --git a/services/web/app/src/infrastructure/Mongoose.js b/services/web/app/src/infrastructure/Mongoose.mjs similarity index 81% rename from services/web/app/src/infrastructure/Mongoose.js rename to services/web/app/src/infrastructure/Mongoose.mjs index a867757dc6..0206ab8de7 100644 --- a/services/web/app/src/infrastructure/Mongoose.js +++ b/services/web/app/src/infrastructure/Mongoose.mjs @@ -1,8 +1,8 @@ -const mongoose = require('mongoose') -const Settings = require('@overleaf/settings') -const Metrics = require('@overleaf/metrics') -const logger = require('@overleaf/logger') -const { addConnectionDrainer } = require('./GracefulShutdown') +import mongoose from 'mongoose' +import Settings from '@overleaf/settings' +import Metrics from '@overleaf/metrics' +import logger from '@overleaf/logger' +import { addConnectionDrainer } from './GracefulShutdown.mjs' mongoose.set('autoIndex', false) mongoose.set('strictQuery', false) @@ -54,4 +54,4 @@ mongoose.Promise = global.Promise mongoose.connectionPromise = connectionPromise -module.exports = mongoose +export default mongoose diff --git a/services/web/app/src/infrastructure/QueueWorkers.mjs b/services/web/app/src/infrastructure/QueueWorkers.mjs index 77540e3d0f..37614a02ed 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.js' +} from './GracefulShutdown.mjs' import EmailHandler from '../Features/Email/EmailHandler.mjs' import logger from '@overleaf/logger' import OError from '@overleaf/o-error' -import Modules from './Modules.js' +import Modules from './Modules.mjs' /** * @typedef {{ diff --git a/services/web/app/src/infrastructure/Queues.mjs b/services/web/app/src/infrastructure/Queues.mjs index 74a44cfd2c..bea46766ca 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.js' +import { addConnectionDrainer } from './GracefulShutdown.mjs' // 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.js b/services/web/app/src/infrastructure/RateLimiter.mjs similarity index 89% rename from services/web/app/src/infrastructure/RateLimiter.js rename to services/web/app/src/infrastructure/RateLimiter.mjs index 6ce80b23a1..5dc7225371 100644 --- a/services/web/app/src/infrastructure/RateLimiter.js +++ b/services/web/app/src/infrastructure/RateLimiter.mjs @@ -1,16 +1,16 @@ -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') +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 rclient = RedisWrapper.client('ratelimiter') /** * Wrapper over the RateLimiterRedis class */ -class RateLimiter { +export class RateLimiter { #opts /** @@ -122,13 +122,13 @@ class RateLimiter { * Shared rate limiters */ -const openProjectRateLimiter = new RateLimiter('open-project', { +export const openProjectRateLimiter = new RateLimiter('open-project', { points: 15, duration: 60, }) // Keep in sync with the can-skip-captcha options. -const overleafLoginRateLimiter = new RateLimiter( +export const overleafLoginRateLimiter = new RateLimiter( 'overleaf-login', Settings.rateLimit?.login?.ip || { points: 20, @@ -137,7 +137,7 @@ const overleafLoginRateLimiter = new RateLimiter( } ) -module.exports = { +export default { RateLimiter, openProjectRateLimiter, overleafLoginRateLimiter, diff --git a/services/web/app/src/infrastructure/RedisWrapper.js b/services/web/app/src/infrastructure/RedisWrapper.mjs similarity index 76% rename from services/web/app/src/infrastructure/RedisWrapper.js rename to services/web/app/src/infrastructure/RedisWrapper.mjs index 4c27328e9b..9acdd85529 100644 --- a/services/web/app/src/infrastructure/RedisWrapper.js +++ b/services/web/app/src/infrastructure/RedisWrapper.mjs @@ -1,6 +1,6 @@ -const Settings = require('@overleaf/settings') -const redis = require('@overleaf/redis-wrapper') -const { addConnectionDrainer } = require('./GracefulShutdown') +import Settings from '@overleaf/settings' +import redis from '@overleaf/redis-wrapper' +import { addConnectionDrainer } from './GracefulShutdown.mjs' /** * A per-feature interface to Redis, looks up the feature in `settings.redis` @@ -23,4 +23,4 @@ async function cleanupTestRedis() { await redis.cleanupTestRedis(rclient) } -module.exports = { client, cleanupTestRedis } +export default { client, cleanupTestRedis } diff --git a/services/web/app/src/infrastructure/RequestContentTypeDetection.js b/services/web/app/src/infrastructure/RequestContentTypeDetection.js deleted file mode 100644 index 6c8c587de6..0000000000 --- a/services/web/app/src/infrastructure/RequestContentTypeDetection.js +++ /dev/null @@ -1,5 +0,0 @@ -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 new file mode 100644 index 0000000000..94046febaf --- /dev/null +++ b/services/web/app/src/infrastructure/RequestContentTypeDetection.mjs @@ -0,0 +1,3 @@ +export function acceptsJson(req) { + return req.accepts(['html', 'json']) === 'json' +} diff --git a/services/web/app/src/infrastructure/Response.js b/services/web/app/src/infrastructure/Response.mjs similarity index 76% rename from services/web/app/src/infrastructure/Response.js rename to services/web/app/src/infrastructure/Response.mjs index 607dbaedc5..75fb7fab2f 100644 --- a/services/web/app/src/infrastructure/Response.js +++ b/services/web/app/src/infrastructure/Response.mjs @@ -1,4 +1,4 @@ -function csvAttachment(res, body, filename) { +export function csvAttachment(res, body, filename) { if (!filename || !filename.endsWith('.csv')) { throw new Error('filename must end with .csv') } @@ -8,23 +8,23 @@ function csvAttachment(res, body, filename) { res.send(body) } -function preparePlainTextResponse(res) { +export function preparePlainTextResponse(res) { res.setHeader('X-Content-Type-Options', 'nosniff') res.contentType('text/plain; charset=utf-8') } -function plainTextResponse(res, body) { +export function plainTextResponse(res, body) { preparePlainTextResponse(res) res.send(body) } -function xmlResponse(res, body) { +export function xmlResponse(res, body) { res.setHeader('X-Content-Type-Options', 'nosniff') res.contentType('application/xml; charset=utf-8') res.send(body) } -function prepareZipAttachment(res, filename) { +export function prepareZipAttachment(res, filename) { if (!filename || !filename.endsWith('.zip')) { throw new Error('filename must end with .zip') } @@ -33,12 +33,12 @@ function prepareZipAttachment(res, filename) { res.setHeader('X-Content-Type-Options', 'nosniff') } -function zipAttachment(res, body, filename) { +export function zipAttachment(res, body, filename) { prepareZipAttachment(res, filename) res.send(body) } -module.exports = { +export default { csvAttachment, plainTextResponse, preparePlainTextResponse, diff --git a/services/web/app/src/infrastructure/ServeStaticWrapper.mjs b/services/web/app/src/infrastructure/ServeStaticWrapper.mjs index fba667e25c..1462b0c327 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.js' +import { plainTextResponse } from './Response.mjs' /* 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 52044bf79a..d973452bd2 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.js' +import HttpPermissionsPolicyMiddleware from './HttpPermissionsPolicy.mjs' 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.js' +import Views from './Views.mjs' 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.js' +import Modules from './Modules.mjs' 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') - Views.precompileViews(app) + await 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 f9368f485f..bcc120c66e 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.js' +} from './GracefulShutdown.mjs' 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 deleted file mode 100644 index 209f56a848..0000000000 --- a/services/web/app/src/infrastructure/Validation.js +++ /dev/null @@ -1,27 +0,0 @@ -// @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 new file mode 100644 index 0000000000..930eb21aa3 --- /dev/null +++ b/services/web/app/src/infrastructure/Validation.mjs @@ -0,0 +1,30 @@ +// @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.js b/services/web/app/src/infrastructure/Views.mjs similarity index 91% rename from services/web/app/src/infrastructure/Views.js rename to services/web/app/src/infrastructure/Views.mjs index fc60eb8e81..61fd0c02f2 100644 --- a/services/web/app/src/infrastructure/Views.js +++ b/services/web/app/src/infrastructure/Views.mjs @@ -1,9 +1,9 @@ -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') +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' // Generate list of view names from app/views function buildViewList() { @@ -147,7 +147,7 @@ function precompileViewsAndCacheToDisk() { ) } -module.exports = { +export default { // for tests PUG_COMPILE_ARGUMENTS, _expectMetaFor, @@ -169,7 +169,7 @@ module.exports = { return viewIncludes }, - precompileViews(app) { + async precompileViews(app) { const startTime = Date.now() let success = 0 let precompiled = 0 @@ -179,7 +179,9 @@ module.exports = { if (fs.existsSync(precompiledFilename)) { logger.debug({ filePath }, 'loading precompiled pug template') try { - pug.cache[filePath] = require(precompiledFilename) + // We need to retrieve the `default` property as a result of using dynamic imports + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object + pug.cache[filePath] = (await import(precompiledFilename)).default precompiled++ continue } catch (err) { @@ -206,7 +208,7 @@ module.exports = { }, } -if (require.main === module) { +if (import.meta.main) { precompileViewsAndCacheToDisk() process.exit(0) } diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.mjs similarity index 84% rename from services/web/app/src/infrastructure/mongodb.js rename to services/web/app/src/infrastructure/mongodb.mjs index 611463e8cc..6ffc38639f 100644 --- a/services/web/app/src/infrastructure/mongodb.js +++ b/services/web/app/src/infrastructure/mongodb.mjs @@ -1,9 +1,9 @@ -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') +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' // Ensure Mongoose is using the same mongodb instance as the mongodb module, // otherwise we will get multiple versions of the ObjectId class. Mongoose @@ -15,10 +15,11 @@ if (Mongoose.mongo.ObjectId !== mongodb.ObjectId) { ) } -const { ObjectId, ReadPreference } = mongodb +export const { ObjectId } = mongodb +const { ReadPreference } = mongodb -const READ_PREFERENCE_PRIMARY = ReadPreference.primary.mode -const READ_PREFERENCE_SECONDARY = Settings.mongo.hasSecondaries +export const READ_PREFERENCE_PRIMARY = ReadPreference.primary.mode +export const READ_PREFERENCE_SECONDARY = Settings.mongo.hasSecondaries ? ReadPreference.secondary.mode : ReadPreference.secondaryPreferred.mode @@ -32,7 +33,7 @@ addConnectionDrainer('mongodb', async () => { }) const internalDb = mongoClient.db() -const db = { +export const db = { contacts: internalDb.collection('contacts'), deletedProjects: internalDb.collection('deletedProjects'), deletedSubscriptions: internalDb.collection('deletedSubscriptions'), @@ -85,36 +86,36 @@ const db = { scriptLogs: internalDb.collection('scriptLogs'), } -const connectionPromise = mongoClient.connect() +export const connectionPromise = mongoClient.connect() -async function getCollectionNames() { +export async function getCollectionNames() { const internalDb = mongoClient.db() const collections = await internalDb.collections() return collections.map(collection => collection.collectionName) } -async function cleanupTestDatabase() { +export async function cleanupTestDatabase() { await MongoUtils.cleanupTestDatabase(mongoClient) } -async function dropTestDatabase() { +export async function dropTestDatabase() { await MongoUtils.dropTestDatabase(mongoClient) } /** * WARNING: Consider using a pre-populated collection from `db` to avoid typos! */ -async function getCollectionInternal(name) { +export async function getCollectionInternal(name) { const internalDb = mongoClient.db() return internalDb.collection(name) } -async function waitForDb() { +export async function waitForDb() { await connectionPromise } -module.exports = { +export default { db, ObjectId, connectionPromise, diff --git a/services/web/app/src/models/DeletedProject.mjs b/services/web/app/src/models/DeletedProject.mjs index 652c052849..9cfeca0ab2 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 b37d2f1ea6..a960ae1fe8 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 17f221c3ce..e8c8e84a9b 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 c06ff3b775..298dee2fa7 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/DocSnapshot.mjs b/services/web/app/src/models/DocSnapshot.mjs index 0a5793f818..fe137a2197 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Feedback.mjs b/services/web/app/src/models/Feedback.mjs index ef583a0ac9..be4e9bf7f2 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 60742e6797..15553ed2b0 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Folder.mjs b/services/web/app/src/models/Folder.mjs index 7ac893f868..a4ba334962 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 de019d40b2..6d0884cf41 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 5d834df350..6598c92d4e 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 c38488aa63..4e87d1fbb1 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Institution.mjs b/services/web/app/src/models/Institution.mjs index a51dbd3f0b..bccf80ddd0 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 d3a9edc9fe..3cc2a22058 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 83ff51fa55..fe20908f53 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/OauthAuthorizationCode.mjs b/services/web/app/src/models/OauthAuthorizationCode.mjs index 9750750f1a..8d080ab026 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 edab377914..11afc4c211 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 fec4769008..e7a4b3968f 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 7e668a60e3..e955189200 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 f584945ce5..7e40305989 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/ProjectInvite.mjs b/services/web/app/src/models/ProjectInvite.mjs index 879cd9f49c..b269eab4cf 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 9bbbd24e54..10d34b2173 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 6db3584619..376409cd85 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 a58a76ea68..5233a47f5f 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 929c7b2600..a47e014401 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 9cc6b8655f..7174e6da9e 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.js' +import Mongoose from '../infrastructure/Mongoose.mjs' 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 b15c81adb4..dc6446e0c9 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 416f637c6f..74e6c1684d 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 3c98e19fb8..70b439a90d 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 4191801f4e..918e813fb6 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/Tag.mjs b/services/web/app/src/models/Tag.mjs index 7824d95d53..d92e9fb616 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 dfa31c09ff..e121f0606e 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose diff --git a/services/web/app/src/models/User.mjs b/services/web/app/src/models/User.mjs index 5b401442b0..6b4a426430 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 11442a9d0c..353feb1ccf 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' 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 50c86127af..1427715dfb 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.js' +import mongoose from '../infrastructure/Mongoose.mjs' const { Schema } = mongoose const Usage = new Schema({ diff --git a/services/web/app/src/router.mjs b/services/web/app/src/router.mjs index 1d50c2acdb..0b5e9c1fa5 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.js' +import Modules from './infrastructure/Modules.mjs' import { RateLimiter, openProjectRateLimiter, overleafLoginRateLimiter, -} from './infrastructure/RateLimiter.js' +} from './infrastructure/RateLimiter.mjs' 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.js' +import { plainTextResponse } from './infrastructure/Response.mjs' import SocketDiagnostics from './Features/SocketDiagnostics/SocketDiagnostics.mjs' import ClsiCacheController from './Features/Compile/ClsiCacheController.mjs' -import AsyncLocalStorage from './infrastructure/AsyncLocalStorage.js' +import AsyncLocalStorage from './infrastructure/AsyncLocalStorage.mjs' 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 99310716fc..ea3ad30e23 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.js" +HELPER_MODULE="app/src/infrastructure/Response.mjs" 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 583f79aefb..11fd0d337a 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.js' +import { db, ObjectId } from '../../../../../app/src/infrastructure/mongodb.mjs' 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 07aeb7cf4d..d66e2a88f0 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 346257a2d2..99a236c7e7 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.js' +} from '../../../app/src/infrastructure/mongodb.mjs' 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 213bcc9714..32f121ab2e 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.js' +import RedisWrapper from '../../../app/src/infrastructure/RedisWrapper.mjs' 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 1675bbba04..90a9137d7f 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 698631d204..ae373c87b3 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 1598309f71..7b985a368a 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 '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' +} 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' import logger from 'logger-sharelatex' import { Project } from '../../../app/src/models/Project.mjs' import { User } from '../../../app/src/models/User.mjs' -import readline from 'readline' +import readline from 'node: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 f33edcddb8..4dab9d62ab 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.js' +import { gracefulShutdown } from '../../../app/src/infrastructure/GracefulShutdown.mjs' 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 32cbac793b..66f396e717 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 6c54e9a3b2..3037be47c6 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.js' +import { ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 f70eebc71f..f397680f12 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 2e38148fa5..61343c03ec 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.js' +import { db } from '../../../../../app/src/infrastructure/mongodb.mjs' 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 50d9874677..4582c1eeeb 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", + "precompile-pug": "node app/src/infrastructure/Views.mjs", "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 40a56bdf43..136ce2aa24 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 80cc4db36c..e7fb4ee238 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 2a404cd7cc..294b4d93a8 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 6ac495325c..e6fe6b7958 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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.js' +import { triggerGracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.mjs' 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 e0d89e0519..572b426cb3 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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.js' -import Validation from '../../app/src/infrastructure/Validation.js' +import { gracefulShutdown } from '../../app/src/infrastructure/GracefulShutdown.mjs' +import Validation from '../../app/src/infrastructure/Validation.mjs' 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 9c929adeb8..32edb44659 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' const OPTS = parseArgs() diff --git a/services/web/scripts/back_fill_staff_access.mjs b/services/web/scripts/back_fill_staff_access.mjs index 10f1edfac9..eb3fcb97e8 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 012c224685..08e8b0c84b 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 ab7259fb45..455b10a5c7 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 97c60e2b58..7c925a0131 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 9325170a51..70daa94486 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 654a79c002..a7efb71307 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 cf4ba7eafd..4655328dc2 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 dae68151b0..aaf339c28e 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.js' +import { waitForDb, db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 ae884e498d..bbcce0fa0c 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 60b44db556..694c30c7ec 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 3518ee9415..a306c7e431 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 e8162d8045..878c93bdc0 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 1180589d1c..ed812c7e89 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 e989d49d15..b840a75ac1 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 33a9bcc1fd..f5f00b8d41 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 31c83a69c0..0898c5df1f 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.js' +import { ObjectId, db } from '../app/src/infrastructure/mongodb.mjs' 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 cff78801e8..5389a63f92 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.js' +import { gracefulShutdown } from '../app/src/infrastructure/GracefulShutdown.mjs' 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 9daabc78e6..3ad6f9ce16 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 4f400ebf9b..82405e96fa 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.js' +import { db, ObjectId } from '../../app/src/infrastructure/mongodb.mjs' 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 8e0cdd5ca3..7fcc56a6d2 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' const OPTS = parseArgs() diff --git a/services/web/scripts/delete_dangling_file_refs.mjs b/services/web/scripts/delete_dangling_file_refs.mjs index 2a290b162c..db72473a6f 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 cb275d4423..ced073617c 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 c9a3c59876..e8878d8028 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 c4468390ec..ef4c66a1b8 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 d90ef64e75..2da28b6a78 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 4fae1fcade..3667b83649 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.js' -import GracefulShutdown from '../app/src/infrastructure/GracefulShutdown.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' +import GracefulShutdown from '../app/src/infrastructure/GracefulShutdown.mjs' 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 9f0f6323ab..d4c6979167 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 062662a5f8..fbd4ac89a4 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 5aa933a634..a073e33102 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 a9bc0636d7..52b98597b4 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 edaeeee612..0e0ea8438e 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 ea6b6533ad..65395a93fc 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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.js' +import FileWriter from '../app/src/infrastructure/FileWriter.mjs' 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 a4f69e47cf..95535f0f54 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 151be8be9a..c2a816e927 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.js' +} from '../app/src/infrastructure/mongodb.mjs' /** * 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 2b0435f56d..8791da6dbb 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.js' +} from '../../app/src/infrastructure/mongodb.mjs' 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 d84c320096..13da1a7a21 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 2e4c3a1434..779114f163 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 c710250965..566b424222 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 f7b66f881a..06362bdea9 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.js' +} from '../../app/src/infrastructure/mongodb.mjs' 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 e253d1f747..1484d91887 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 05d4f92ab9..fa8868920a 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 24080491b2..6b805301cc 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.js' +} from '../../app/src/infrastructure/mongodb.mjs' 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 f28417c1ec..44c5655bed 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' const OPTS = parseArgs() diff --git a/services/web/scripts/recover_docs_from_redis.mjs b/services/web/scripts/recover_docs_from_redis.mjs index 4e5a4ae285..faae5141bc 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.js' +import { db, ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 ab35c1535e..7c7ce9c9ff 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.js' +} from '../../app/src/infrastructure/mongodb.mjs' /** * @import { ObjectId } from 'mongodb-legacy' diff --git a/services/web/scripts/refresh_features.mjs b/services/web/scripts/refresh_features.mjs index 23c6ad44cb..c1f7e6a8d2 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 84f3a7f61e..7b5666aede 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 4f85807b4b..32600484f0 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 f138501f0e..5380852bfa 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.js' +} from '../app/src/infrastructure/mongodb.mjs' 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 64073607a9..e8e112af1c 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 89044949fa..b9570f6e4c 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 47fa90c6eb..eb353b655a 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.js' -import mongoose from '../app/src/infrastructure/Mongoose.js' +import mongodb from '../app/src/infrastructure/mongodb.mjs' +import mongoose from '../app/src/infrastructure/Mongoose.mjs' 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 de702602ea..f2327be9e2 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.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient, diff --git a/services/web/scripts/stripe/archive_prices_by_version_key.mjs b/services/web/scripts/stripe/archive_prices_by_version_key.mjs index 2c7c505a7f..272c72f66e 100755 --- a/services/web/scripts/stripe/archive_prices_by_version_key.mjs +++ b/services/web/scripts/stripe/archive_prices_by_version_key.mjs @@ -25,7 +25,7 @@ */ import minimist from 'minimist' -import { z } from '../../app/src/infrastructure/Validation.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' diff --git a/services/web/scripts/stripe/export_products_from_environment.mjs b/services/web/scripts/stripe/export_products_from_environment.mjs index 26863bb431..a59777e2de 100755 --- a/services/web/scripts/stripe/export_products_from_environment.mjs +++ b/services/web/scripts/stripe/export_products_from_environment.mjs @@ -21,7 +21,7 @@ import minimist from 'minimist' import fs from 'node:fs' -import { z } from '../../app/src/infrastructure/Validation.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' diff --git a/services/web/scripts/stripe/import_products_to_environment.mjs b/services/web/scripts/stripe/import_products_to_environment.mjs index aaf6e2def7..0a27d3c40a 100755 --- a/services/web/scripts/stripe/import_products_to_environment.mjs +++ b/services/web/scripts/stripe/import_products_to_environment.mjs @@ -22,7 +22,7 @@ import minimist from 'minimist' import fs from 'node:fs' -import { z } from '../../app/src/infrastructure/Validation.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' 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 c2425b6ddd..0597460a00 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.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' diff --git a/services/web/scripts/stripe/update_prices_from_csv.mjs b/services/web/scripts/stripe/update_prices_from_csv.mjs index 2ca85c0a4e..870dca7bb5 100644 --- a/services/web/scripts/stripe/update_prices_from_csv.mjs +++ b/services/web/scripts/stripe/update_prices_from_csv.mjs @@ -26,7 +26,7 @@ import fs from 'node:fs' // https://github.com/import-js/eslint-plugin-import/issues/1810 // eslint-disable-next-line import/no-unresolved import * as csv from 'csv/sync' -import { z } from '../../app/src/infrastructure/Validation.js' +import { z } from '../../app/src/infrastructure/Validation.mjs' import { scriptRunner } from '../lib/ScriptRunner.mjs' import { getRegionClient } from '../../modules/subscriptions/app/src/StripeClient.mjs' import PlansLocator from '../../app/src/Features/Subscription/PlansLocator.mjs' diff --git a/services/web/scripts/suspend_users.mjs b/services/web/scripts/suspend_users.mjs index 76d7eef2ca..e7927b6f33 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.js' +import { ObjectId } from '../app/src/infrastructure/mongodb.mjs' 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 dad141b8f1..d678dbf5cd 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 63788bef6d..30746b6eec 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.js' +import { db } from '../app/src/infrastructure/mongodb.mjs' 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 e40e065d51..60e74304fe 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 bdae9d8f26..19940237cc 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 8f76ad666d..9f31b18224 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 dc86f8897b..6428920926 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.js' +import { db } from '../../app/src/infrastructure/mongodb.mjs' 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 d56d7e877e..4554ce2d46 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 599e684447..7c4a76be4c 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 ad15f2fed5..90fc37c6c1 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 1b82b129d3..0759a2da0f 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 e93881dcf6..eaa222605b 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + '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" } })', ]) 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.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + '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" } })', ], { 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.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + '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" } })', ], { 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.js"; batchedUpdateWithResultHandling(db.systemmessages, { content: { $ne: "42" }}, { $set: { content: "42" } })', + '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" } })', ], { env: { diff --git a/services/web/test/acceptance/src/CaptchaTests.mjs b/services/web/test/acceptance/src/CaptchaTests.mjs index 223fe02cb0..7774492e31 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 1070bad11b..b8dbbe21c5 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.js' +import { ObjectId, db } from '../../../app/src/infrastructure/mongodb.mjs' 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 5fa88b6fb3..f04dfaccd6 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 1f27726876..b5fd0433d8 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 fc69d7750a..8e951c5554 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 39d1ba053d..b693c9b96d 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 ffa8eb7618..422a95489b 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 8010aac407..cc25097d3e 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.js' +import { plainTextResponse } from '../../../app/src/infrastructure/Response.mjs' const User = UserHelper.promises diff --git a/services/web/test/acceptance/src/MalformedFiletreesTests.mjs b/services/web/test/acceptance/src/MalformedFiletreesTests.mjs index 16282d592d..63f60ffff4 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 1821477bdf..ca22cecc3e 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 4e4cf9c5c1..e7900993db 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 33d8610f49..6c21681e65 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.js' +import LockManager from '../../../app/src/infrastructure/LockManager.mjs' 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 801ebfd455..bcb6d1b963 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 7aa0c895d6..1f14faa689 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.js' +import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.mjs' 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 1ffba5dfd5..a3f4c5c9a9 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.js' +import { db } from '../../../app/src/infrastructure/mongodb.mjs' 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 b2544a43cf..a85e050c16 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.js' +import { gracefulShutdown } from '../../../../app/src/infrastructure/GracefulShutdown.mjs' 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.js' +import Modules from '../../../../app/src/infrastructure/Modules.mjs' 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 0351c09a31..35ce209ea1 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.js' +} from '../../../../app/src/infrastructure/mongodb.mjs' 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 e38d7ad80e..33fdfbbbbc 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.js' +import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.mjs' 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 afa1297de0..48aa2f7b60 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.js' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' 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.js' +import Modules from '../../../../app/src/infrastructure/Modules.mjs' 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 3bc4d801f1..f9010d69fd 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.js' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' 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 d14d41c4c3..b7332f5c3a 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.js' +import { RateLimiter } from '../../../../app/src/infrastructure/RateLimiter.mjs' const { ObjectId } = mongodb diff --git a/services/web/test/acceptance/src/mocks/MockClsiApi.mjs b/services/web/test/acceptance/src/mocks/MockClsiApi.mjs index de2fc488c0..32db8f1847 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.js' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' 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 3a73e62dc0..b3726a4524 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.js' +import { db, ObjectId } from '../../../../app/src/infrastructure/mongodb.mjs' 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 2aa47f83f7..0425d986e5 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.js' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' 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 82908dc948..7ff95ec395 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.js' +import { plainTextResponse } from '../../../../app/src/infrastructure/Response.mjs' const { ObjectId } = mongodb diff --git a/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs b/services/web/test/acceptance/src/mocks/MockRecurlyApi.mjs index 9876b86eda..d25789d92c 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.js' +import { xmlResponse } from '../../../../app/src/infrastructure/Response.mjs' 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 620b073317..3b424c7774 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.js' +} from '../../../../app/src/infrastructure/Response.mjs' 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 953c3fca62..befbe0ec28 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.js' +} from '../../../../app/src/infrastructure/RateLimiter.mjs' 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 82c5d741c6..423573421f 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.js', () => ({ +vi.mock('../../../../app/src/infrastructure/Metrics.mjs', () => ({ 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 9a66ae0243..a4912f4cbc 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ 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 d715d3e600..ad74c4dfc3 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.js', + '../../../../app/src/infrastructure/RateLimiter.mjs', () => 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 9e221eb573..a7f856d996 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/RateLimiter.mjs', () => ({ 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 fdd757f03f..5c6640c8f4 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 { cleanupTestRedis } from '../../../../app/src/infrastructure/RedisWrapper.js' +import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.mjs' const { ObjectId } = mongodb describe('CooldownManager', function () { - beforeEach(cleanupTestRedis) + beforeEach(RedisWrapper.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 b683cc5d14..6cd4a7e11a 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ 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 730d9c811a..81c5a7b13b 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/FileWriter.mjs', () => ({ 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 4a06a1cf59..6d409ca120 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/mongodb.mjs', () => ({ 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 e8d3ea2052..cf5929558e 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.js' +} from '../../../../app/src/infrastructure/mongodb.mjs' 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 e13195af70..450ccae874 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/Metrics.mjs', () => ({ 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 df412f2d39..e7843c8b41 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.js' +} from '../../../../app/src/infrastructure/mongodb.mjs' 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 ef45cefa07..84bf6d6531 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/mongodb.mjs', () => ({ 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 7492df2e1a..5bdd73eef4 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.js', () => ({ + vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({ default: ctx.Modules, })) diff --git a/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js b/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs similarity index 65% rename from services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js rename to services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs index 407510921b..427d638c34 100644 --- a/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicyTests.js +++ b/services/web/test/unit/src/infrastructure/HTTPPermissionsPolicy.test.mjs @@ -1,18 +1,18 @@ -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') +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' describe('HttpPermissionsPolicy', function () { - 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()) + 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) }) describe('when a single blocked policy element is provided', function () { @@ -23,9 +23,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - return expect(httpPermissionsMiddleware.policy).to.equal( - 'accelerometer=()' - ) + expect(httpPermissionsMiddleware.policy).to.equal('accelerometer=()') }) }) @@ -37,7 +35,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - return expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') + expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') }) }) @@ -50,7 +48,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - return expect(httpPermissionsMiddleware.policy).to.equal( + expect(httpPermissionsMiddleware.policy).to.equal( 'usb=(), hid=(), camera=(self https://example.com), fullscreen=(self)' ) }) @@ -62,7 +60,7 @@ describe('HttpPermissionsPolicy', function () { blocked: ['usb'], allowed: { usb: 'self' }, } - return expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( + expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( 'Invalid Permissions-Policy header configuration' ) }) @@ -74,7 +72,7 @@ describe('HttpPermissionsPolicy', function () { blocked: ['usb'], allowed: { camera: '' }, } - return expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( + expect(() => new HttpPermissionsPolicyMiddleware(policy)).to.throw( 'Invalid Permissions-Policy header configuration' ) }) @@ -89,7 +87,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - return expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') + expect(httpPermissionsMiddleware.policy).to.equal('camera=(self)') }) }) @@ -102,7 +100,7 @@ describe('HttpPermissionsPolicy', function () { const httpPermissionsMiddleware = new HttpPermissionsPolicyMiddleware( policy ) - return expect(httpPermissionsMiddleware.policy).to.equal('usb=()') + 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 deleted file mode 100644 index a5ec96cca7..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js +++ /dev/null @@ -1,58 +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 - */ -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 new file mode 100644 index 0000000000..7607e74b4b --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.test.mjs @@ -0,0 +1,64 @@ +/* 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 new file mode 100644 index 0000000000..0c9b852e6b --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/getLock.test.mjs @@ -0,0 +1,209 @@ +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 deleted file mode 100644 index 07bd6820c9..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js +++ /dev/null @@ -1,194 +0,0 @@ -/* 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 new file mode 100644 index 0000000000..f44d8a555d --- /dev/null +++ b/services/web/test/unit/src/infrastructure/LockManager/tryLock.test.mjs @@ -0,0 +1,88 @@ +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 deleted file mode 100644 index 9252797f2f..0000000000 --- a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js +++ /dev/null @@ -1,81 +0,0 @@ -/* 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 new file mode 100644 index 0000000000..bb2fccaf68 --- /dev/null +++ b/services/web/test/unit/src/infrastructure/RateLimiter.test.mjs @@ -0,0 +1,95 @@ +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 deleted file mode 100644 index 4d0b2c2f98..0000000000 --- a/services/web/test/unit/src/infrastructure/RateLimiterTests.js +++ /dev/null @@ -1,95 +0,0 @@ -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/RequestContentTypeDetectionTests.js b/services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs similarity index 52% rename from services/web/test/unit/src/infrastructure/RequestContentTypeDetectionTests.js rename to services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs index b214a71f56..2d0ae588c4 100644 --- a/services/web/test/unit/src/infrastructure/RequestContentTypeDetectionTests.js +++ b/services/web/test/unit/src/infrastructure/RequestContentTypeDetection.test.mjs @@ -1,24 +1,23 @@ -const accepts = require('accepts') -const { expect } = require('chai') +import accepts from 'accepts' +import { expect, vi } from 'vitest' +import MockRequest from '../helpers/MockRequestVitest.mjs' const MODULE_PATH = - '../../../../app/src/infrastructure/RequestContentTypeDetection.js' -const MockRequest = require('../helpers/MockRequest') -const SandboxedModule = require('sandboxed-module') + '../../../../app/src/infrastructure/RequestContentTypeDetection.mjs' describe('RequestContentTypeDetection', function () { - before(function () { - this.RequestContentTypeDetection = SandboxedModule.require(MODULE_PATH) - this.req = new MockRequest() - this.req.accepts = function (...args) { + beforeEach(async function (ctx) { + ctx.RequestContentTypeDetection = await import(MODULE_PATH) + ctx.req = new MockRequest(vi) + ctx.req.accepts = function (...args) { return accepts(this).type(...args) } }) describe('isJson=true', function () { function expectJson(type) { - it(type, function () { - this.req.headers.accept = type - expect(this.RequestContentTypeDetection.acceptsJson(this.req)).to.equal( + it(type, function (ctx) { + ctx.req.headers.accept = type + expect(ctx.RequestContentTypeDetection.acceptsJson(ctx.req)).to.equal( true ) }) @@ -31,9 +30,9 @@ describe('RequestContentTypeDetection', function () { describe('isJson=false', function () { function expectNonJson(type) { - it(type, function () { - this.req.headers.accept = type - expect(this.RequestContentTypeDetection.acceptsJson(this.req)).to.equal( + it(type, function (ctx) { + ctx.req.headers.accept = type + expect(ctx.RequestContentTypeDetection.acceptsJson(ctx.req)).to.equal( false ) }) diff --git a/services/web/test/unit/src/infrastructure/Views.js b/services/web/test/unit/src/infrastructure/Views.test.mjs similarity index 78% rename from services/web/test/unit/src/infrastructure/Views.js rename to services/web/test/unit/src/infrastructure/Views.test.mjs index 7b601f5d9c..cef6db5f36 100644 --- a/services/web/test/unit/src/infrastructure/Views.js +++ b/services/web/test/unit/src/infrastructure/Views.test.mjs @@ -1,21 +1,19 @@ -/* eslint-disable no-template-curly-in-string */ +import { vi, expect } from 'vitest' -const { expect } = require('chai') -const pug = require('pug') -const modulePath = '../../../../app/src/infrastructure/Views.js' -const SandboxedModule = require('sandboxed-module') +import pug from 'pug' +const modulePath = '../../../../app/src/infrastructure/Views.mjs' describe('Views', function () { - beforeEach(function () { - this.Views = SandboxedModule.require(modulePath, { - requires: { - '@overleaf/settings': (this.settings = { - viewIncludes: { - someInclude: 'path/to/_include.pug', - }, - }), - }, - }) + beforeEach(async function (ctx) { + vi.doMock('@overleaf/settings', () => ({ + default: (ctx.settings = { + viewIncludes: { + someInclude: 'path/to/_include.pug', + }, + }), + })) + + ctx.Views = (await import(modulePath)).default }) describe('_expectMetaFor', function () { @@ -52,8 +50,8 @@ describe('Views', function () { }, ] for (const { name, filename, firstLine, expectMeta } of cases) { - it(name, function () { - expect(this.Views._expectMetaFor(filename, firstLine)).to.equal( + it(name, function (ctx) { + expect(ctx.Views._expectMetaFor(filename, firstLine)).to.equal( expectMeta ) }) @@ -100,7 +98,9 @@ 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 () { - const res = this.Views._findAllMetaTags( - compiled || pug.compileClient(src, this.Views.PUG_COMPILE_ARGUMENTS) + it(name, function (ctx) { + const res = ctx.Views._findAllMetaTags( + compiled || pug.compileClient(src, ctx.Views.PUG_COMPILE_ARGUMENTS) ) expect(res).to.deep.equal({ found, duplicates }) })