Commit Graph

60 Commits

Author SHA1 Message Date
Girish Ramakrishnan b8ae46b6df add passkey tests 2026-02-17 18:05:14 +01:00
Girish Ramakrishnan 36aa641cb9 migrate to "export default"
also, set no-use-before-define in linter
2026-02-14 15:43:24 +01:00
Girish Ramakrishnan 96dc79cfe6 Migrate codebase from CommonJS to ES Modules
- Convert all require()/module.exports to import/export across 260+ files
- Add "type": "module" to package.json to enable ESM by default
- Add migrations/package.json with "type": "commonjs" to keep db-migrate compatible
- Convert eslint.config.js to ESM with sourceType: "module"
- Replace __dirname/__filename with import.meta.dirname/import.meta.filename
- Replace require.main === module with process.argv[1] === import.meta.filename
- Remove 'use strict' directives (implicit in ESM)
- Convert dynamic require() in switch statements to static import lookup maps
  (dns.js, domains.js, backupformats.js, backupsites.js, network.js)
- Extract self-referencing exports.CONSTANT patterns into standalone const
  declarations (apps.js, services.js, locks.js, users.js, mail.js, etc.)
- Lazify SERVICES object in services.js to avoid circular dependency TDZ issues
- Add clearMailQueue() to mailer.js for ESM-safe queue clearing in tests
- Add _setMockApp() to ldapserver.js for ESM-safe test mocking
- Add _setMockResolve() wrapper to dig.js for ESM-safe DNS mocking in tests
- Convert backupupload.js to use dynamic imports so --check exits before
  loading the module graph (which requires BOX_ENV)
- Update check-install to use ESM import for infra_version.js
- Convert scripts/ (hotfix, release, remote_hotfix.js, find-unused-translations)
- All 1315 tests passing

Migration stats (AI-assisted using Cursor with Claude):
- Wall clock time: ~3-4 hours
- Assistant completions: ~80-100
- Estimated token usage: ~1-2M tokens

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 15:11:45 +01:00
Girish Ramakrishnan 12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30
Girish Ramakrishnan 622aecfd6d users: add unset route for avatar
also add missing tests for avatar and profile locking
2025-07-15 10:06:26 +02:00
Girish Ramakrishnan be9adb64bb fix tests 2025-07-15 09:07:23 +02:00
Girish Ramakrishnan 6ac0cd421a use the @cloudron/superagent module 2025-07-10 10:56:05 +02:00
Girish Ramakrishnan 24d93ea87d test: fix status code 2025-07-01 13:04:21 +02:00
Girish Ramakrishnan a93c85ebc9 profile: drop gravatar support
gravatar is owned by an external entity (Automattic) and we have an
unnecessary dep to this service. users can just upload a profile pic
2025-06-08 18:12:40 +02:00
Girish Ramakrishnan 344782099f add explicit unset for the image routes
the initial motivation was to fix up the profile avatar rule which
had a mix of json or multipart. this style does not work well with
express 5
2025-06-06 18:58:49 +02:00
Girish Ramakrishnan 0f7bc9be52 GET requests should not use json middleware 2025-06-06 17:18:39 +02:00
Girish Ramakrishnan 5342dae5b3 tokens: add ip restriction 2025-03-07 17:50:50 +01:00
Girish Ramakrishnan 8e58349bfa replace with custom superagent based on fetch API 2025-02-15 15:14:09 +01:00
Girish Ramakrishnan 6525504923 profile: store preferred language in the database 2024-02-26 13:30:35 +01:00
Johannes Zellner 8b7c5a65d6 Fixup profile avatar tests 2024-02-06 20:48:27 +01:00
Girish Ramakrishnan f43a601e86 profile: email change now requires password 2024-01-18 18:11:42 +01:00
Girish Ramakrishnan 6c4aa605df move various login routes under auth/ 2023-08-10 16:24:10 +05:30
Girish Ramakrishnan 515b1db9d0 Fix tests 2021-11-17 11:35:44 -08:00
Johannes Zellner 59cbac0171 Require password for fallback email change 2021-09-09 23:22:00 +02:00
Girish Ramakrishnan a1c61facdc merge userdb.js into users.js 2021-07-16 22:33:22 -07:00
Johannes Zellner ede72ab05c Add more avatar tests 2021-07-09 12:30:47 +02:00
Johannes Zellner 35dc2141ea Make profile route tests work 2021-07-09 12:07:09 +02:00
Girish Ramakrishnan 147c8df6e3 async'ify avatar and apppassword code 2021-06-25 23:32:21 -07:00
Girish Ramakrishnan fe8358c3e3 test: remove tokendb from users-test 2021-06-05 15:14:07 -07:00
Girish Ramakrishnan 9c49ca5d2e test: move the 2fa tests into profile 2021-06-05 10:43:41 -07:00
Girish Ramakrishnan 7bee7b9ef8 tokens: async'ify 2021-06-04 13:06:38 -07:00
Girish Ramakrishnan 4b93b31c3d SCOPE_* vars are unused now 2020-02-11 17:37:12 -08:00
Girish Ramakrishnan 9b74bb73aa config.js is dead, long live config.js
we use settings now
2019-07-26 14:51:51 -07:00
Girish Ramakrishnan 12eae1eff2 Make port a constant 2019-07-25 16:08:54 -07:00
Girish Ramakrishnan 6f33900f85 Fix failing test 2019-06-21 15:05:28 -07:00
Johannes Zellner c2f464ea75 password change api now returns 400 instead of 403 2019-05-13 23:46:38 +02:00
Girish Ramakrishnan fa5415b1eb get rid of mail queue
this prevents us from returning mail errors synchronously
2019-04-15 16:39:09 -07:00
Girish Ramakrishnan e8c11f6e15 Fix tests 2019-02-15 14:56:51 -08:00
Johannes Zellner 54c96d98d1 Remove all individual test timeouts and ignore timeouts toplevel 2018-12-03 12:24:04 +01:00
Girish Ramakrishnan e49b57294d Give optional name for tokens 2018-08-27 14:59:52 -07:00
Girish Ramakrishnan fba70d888b Remove tokenScopes
decided that the UI won't use this any more and will just the admin flag
2018-08-03 10:07:23 -07:00
Girish Ramakrishnan 7880a2f9c3 API returns 403 for incorrect password 2018-06-20 09:27:24 -07:00
Girish Ramakrishnan ff73bc121f Make tokenScope plural 2018-06-18 15:10:02 -07:00
Girish Ramakrishnan 898cbd01b3 tokens table always has canonical scope 2018-06-17 23:11:36 -07:00
Girish Ramakrishnan ad6bc191f9 Make hasScopes take an array 2018-06-17 21:06:17 -07:00
Girish Ramakrishnan f24a099e79 Remove user.admin property
The UI will now base itself entirely off the scopes of the token
2018-06-17 16:49:56 -07:00
Girish Ramakrishnan 156ffb40c9 Remove scope from users.get 2018-06-17 16:07:20 -07:00
Girish Ramakrishnan e8d9597345 Fix various error codes
401 - bad password/wrong password
403 - authenticated but not authorized
409 - conflict
2018-06-15 23:15:30 -07:00
Girish Ramakrishnan a1020ec6b8 remove /user from profile route 2018-05-13 21:53:06 -07:00
Girish Ramakrishnan 61d803f528 Use SCOPE_ANY everywhere 2018-04-30 21:44:24 -07:00
Girish Ramakrishnan e0da6679e9 Move user routes to /api/v1/user 2018-04-26 19:57:44 -07:00
Johannes Zellner 9f29438b34 Allow changing fallbackEmail via the profile api 2018-01-22 15:55:55 +01:00
Girish Ramakrishnan 4b642a407f remove caas dep from tests 2018-01-18 13:50:57 -08:00
Girish Ramakrishnan 68c26c1d12 Fix route/ tests 2017-11-27 16:01:52 -08:00
Girish Ramakrishnan 536c16929b Remove showTutorial 2017-01-17 09:11:34 -08:00