Commit Graph

122 Commits

Author SHA1 Message Date
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 a9ae34b149 community: download iconUrl
also rename existing db field appStoreIcon to packageIcon
2026-02-06 19:13:55 +01:00
Girish Ramakrishnan 0969bb9824 test: fix storage test 2025-06-06 08:34:21 +02:00
Girish Ramakrishnan ba6ba44955 use enum for access levels 2024-12-19 12:24:08 +01:00
Girish Ramakrishnan aeddaa4566 apps: rework portBindings
ports is REST API input . Map of env var to the host port
portBinding is the database structure. Map of env var to host port, count, type etc

also, rename portCount -> count in various places to keep things consistent
2024-07-17 00:25:47 +02:00
Girish Ramakrishnan 620c49cf76 Fix signature of checkForPortBindingsConflict 2024-07-16 19:31:54 +02:00
Girish Ramakrishnan 692be297b3 app proxy: protect code accessing containerId 2024-06-10 11:23:29 +02:00
Johannes Zellner a677dc3981 Fixup crontab tests 2024-05-15 15:17:42 +02:00
Girish Ramakrishnan b4e4f26361 Rework cpuShares into cpuQuota
cpuShares is the relative weight wrt other apps. This is used when
there is contention for CPU. If we want this, maybe we implement
a UI where we show all the apps and let the user re-order them.
As it stands, it is confusing.

cpuQuota is a more straightforward "hard limit" of the CPU% that you
want the app to consume.

Can be tested with : stress -c 8 -t 20s
2024-04-10 18:25:14 +02:00
Johannes Zellner dec7bc3ca3 Check for portBindings with range outside the db constraint for now 2024-02-29 15:20:17 +01:00
Girish Ramakrishnan 5927f397a3 translate port bindings after validation 2024-02-27 13:19:19 +01:00
Girish Ramakrishnan 79af6c1a68 On dashboard or email location change, reconfigure immediately 2023-08-21 18:34:07 +05:30
Girish Ramakrishnan 28bfab6700 LOCATION_TYPE can move into location.js 2023-08-17 16:05:19 +05:30
Girish Ramakrishnan ee836e6646 mail: 'my' location is available as mail location
move the reserve domains check to app location validation code
2023-08-01 19:33:59 +05:30
Girish Ramakrishnan 1f4c71dcd6 tests: configure apps needs an array 2023-07-28 14:46:31 +05:30
Johannes Zellner a5d244b593 Add tests for proxy app upstreamUri 2022-11-23 14:36:57 +01:00
Girish Ramakrishnan 20d722f076 Fix test 2022-08-15 20:45:55 +02:00
Girish Ramakrishnan 9fcd6f9c0a cron: add @service which is probably clearer than @reboot in app context 2022-05-20 10:57:44 -07:00
Girish Ramakrishnan 17910584ca cron: add extensions
https://www.man7.org/linux/man-pages/man5/crontab.5.html#EXTENSIONS
2022-05-20 10:53:30 -07:00
Girish Ramakrishnan e8d08968a1 rename location to subdomain
the primary subdomain was previously called 'location'. but the alias/secondary/redirect
subdomain is called 'subdomain'. this makes it all consistent.

location terminology is now used for { subdomain, domain } pair
2022-01-16 12:48:29 -08:00
Girish Ramakrishnan 515b1db9d0 Fix tests 2021-11-17 11:35:44 -08:00
Girish Ramakrishnan 13644624df add crontab tests 2021-09-28 11:08:10 -07:00
Johannes Zellner 5b70c055cc Fixup accessLevel tests 2021-09-22 12:07:31 +02:00
Girish Ramakrishnan 6c9b8c8fa8 apps: fix various operators issues
part of #791
2021-09-21 18:20:03 -07:00
Girish Ramakrishnan bb2ad0e986 Implement operator role for apps
There are two main use cases:
* A consultant/contractor/external developer is given access to just an app.
* A "service" personnel (say upstream app author) is to be given access to single app
for debugging.

Since, this is an "app admin", they are also given access to apps to be consistent with
the idea that Cloudron admin has access to all apps.

part of #791
2021-09-21 12:30:02 -07:00
Girish Ramakrishnan f44fa2cf47 apps: hasAccessTo -> canAccess 2021-09-21 10:13:06 -07:00
Girish Ramakrishnan 77f5cb183b merge appdb.js into apps.js 2021-08-23 15:35:38 -07:00
Girish Ramakrishnan a1c61facdc merge userdb.js into users.js 2021-07-16 22:33:22 -07:00
Girish Ramakrishnan 004e812d60 merge backupdb into backups.js 2021-07-14 15:10:45 -07:00
Johannes Zellner b87ba2f873 Fixup some app tests using test/common.js 2021-07-09 17:09:10 +02:00
Girish Ramakrishnan 31498afe39 async'ify the groups code 2021-06-29 09:08:45 -07:00
Girish Ramakrishnan 963e92b517 store fallback certs in the database 2021-05-04 22:30:28 -07:00
Girish Ramakrishnan 176388111c tokens: add lastUsedTime 2021-03-16 16:04:17 -07:00
Girish Ramakrishnan 663e0952fc move wellKnownJson to domains
after some more thought:
* If app moves to another location, user has to remember to move all this config
* It's not really associated with an app. It's to do with the domain info
* We can put some hints in the UI if app is missing.

part of #703
2020-12-23 17:13:22 -08:00
Girish Ramakrishnan c7a7456ec9 more test fixing 2020-09-23 15:31:07 -07:00
Girish Ramakrishnan 3507269321 Allow mail server name to be configurable
Fixes #721
2020-08-17 21:49:59 -07:00
Girish Ramakrishnan 1453178693 settings.setAdmin -> setAdminLocation 2020-08-15 19:24:32 -07:00
Girish Ramakrishnan f94ff49fb9 users: replace modifiedAt with ts 2020-07-09 16:02:49 -07:00
Johannes Zellner c5e84d5469 Add source property to userGroups 2020-06-04 13:25:55 +02:00
Girish Ramakrishnan 3fec599c0c remove mail domain add/remove API
merge this as a transaction into domains API

fixes #669
2020-03-31 14:48:19 -07:00
Johannes Zellner f78571e46d Support reserved port ranges 2020-03-30 10:01:52 +02:00
Girish Ramakrishnan 0e156b9376 migrate permissions and admin flag to user.role 2020-02-21 16:49:20 -08:00
Girish Ramakrishnan c537dfabb2 add manage user permission 2020-02-13 22:49:58 -08:00
Girish Ramakrishnan 4ba9f80d44 apps: configure cpuShares 2020-01-28 22:16:25 -08:00
Girish Ramakrishnan 5509406395 add mailboxDomain field to apps table 2019-11-15 09:40:35 -08:00
Girish Ramakrishnan bce1efb77c Move AppsError to BoxError 2019-10-24 10:39:47 -07:00
Girish Ramakrishnan 9c12f1fe15 Add field to configure the reverse proxy
part of #596
2019-10-14 15:05:25 -07:00
Girish Ramakrishnan c3c9c2f39a Always pass restoreConfig for the restore case 2019-09-30 09:47:14 -07:00
Girish Ramakrishnan 85c13cae58 Fix platform update logic 2019-09-24 21:21:49 -07:00