Commit Graph

326 Commits

Author SHA1 Message Date
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
Johannes Zellner 5bd803e6b4 hetznercloud wants name instead of search_name for zones 2026-01-29 15:35:29 +01:00
Girish Ramakrishnan c71d915a4b typo 2026-01-12 18:33:22 +01:00
Johannes Zellner 1cd82dcd4c Revert old hetzner dns api file 2025-10-20 15:17:02 +02:00
Johannes Zellner 5ba30d0236 add hetznercloud DNS provider 2025-10-20 15:05:19 +02:00
Girish Ramakrishnan a7d8a8fd1f godaddy: add missing customNameservers check 2025-10-10 16:31:01 +02:00
Girish Ramakrishnan 43e426ab9f Revert "Add no-use-before-define linter rule"
This reverts commit fdcc5d68a2.

Unfortunately, this requires us to move exports to the bottom.
This in turn causes circular dep issues and also access of
exports.GLOBAL_VAR in the global context
2025-10-08 21:17:52 +02:00
Girish Ramakrishnan f2316ec84e storage: remove usage of secret placeholder 2025-10-08 15:49:56 +02:00
Girish Ramakrishnan e9318d7f11 cloudflare: when proxying is enabled, use a valid IP 2025-10-08 14:50:00 +02:00
Girish Ramakrishnan 01d7d41c17 domains: remove SECRET_PLACEHOLDER from responses 2025-10-08 14:32:24 +02: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 6ac0cd421a use the @cloudron/superagent module 2025-07-10 10:56:05 +02:00
Johannes Zellner e898639168 Use error message from DigitalOcean if available 2025-06-13 16:02:27 +02:00
Girish Ramakrishnan a7c6e36ec3 replace ipaddr.js 2025-05-06 16:26:35 +02:00
Johannes Zellner 5be2eb1c9a Fix superagent usage 2025-04-19 16:33:12 +02:00
Girish Ramakrishnan 6aca198428 domains: add option to set custom/vanity nameservers
this flag skips the NS name validation when a custom nameserver is set
i.e not to the provider's NS but uses the provider's API.
2025-03-02 09:52:08 +01:00
Girish Ramakrishnan 8e58349bfa replace with custom superagent based on fetch API 2025-02-15 15:14:09 +01:00
Girish Ramakrishnan dd5e4adc73 replace underscore with our own
we only need like 5 simple functions
2025-02-13 14:14:34 +01:00
Girish Ramakrishnan 7322006455 test: fix route53 tests 2025-02-11 11:29:43 +01:00
Girish Ramakrishnan 58fcca58fc domains: migrate route53 to aws sdk v3 2025-02-10 17:42:56 +01:00
Girish Ramakrishnan 6c7341b9f3 cloudflare: list recordrecord API does not return zone_id anymore 2025-01-31 23:05:16 +01:00
Girish Ramakrishnan d1da77d6bc const 2025-01-31 09:47:31 +01:00
Girish Ramakrishnan 6cd97d2cb9 remove usage of util.format 2025-01-31 09:46:06 +01:00
Girish Ramakrishnan 3728d8ecc1 porkbun: incorrect usage of promises 2024-12-16 14:07:03 +01:00
Girish Ramakrishnan dcca524726 porkbun: timeout for all requests flat out 2024-12-16 10:03:16 +01:00
Girish Ramakrishnan 1d0f3a08f4 porkbun: it is really slow 2024-12-16 09:46:38 +01:00
Girish Ramakrishnan 26caacc12e Fix debugs 2024-11-30 10:18:48 +01:00
Girish Ramakrishnan 78520e09c3 domains: add inwx provider 2024-11-26 19:13:33 +05:30
Girish Ramakrishnan 5e3857fd3d Fix assert
NETWORK_ERROR is usually an AggregateError which causes an
assert in BoxError
2024-11-19 17:08:55 +05:30
Girish Ramakrishnan ba75c7ddaa porkbun: api endpoint has changed
https://porkbun.com/api/json/v3/documentation
2024-10-12 10:58:21 +02:00
Girish Ramakrishnan ce5a2b1f0a gandi: use PAT token instead
https://api.gandi.net/docs/authentication/
2024-10-08 17:51:01 +02:00
Girish Ramakrishnan 777834d790 dig: set tries parameter 2024-09-18 15:25:48 +02:00
Girish Ramakrishnan cd5cae33ce dns: switch over to systemd for the host
this changes unbound to listen to 127.0.0.150 (150 is roman CL)

we cannot only bind on docker bridge because unbound is relied
upon for the initial domain setup. docker itself is only initialized
when the platform initializes
2024-04-29 11:06:03 +02:00
Girish Ramakrishnan efa1acddd4 dns: unregister domains if type is disabled 2024-04-27 18:43:31 +02:00
Girish Ramakrishnan 2da361a1f2 waitfordns: resolve and check against NS' IPv6 address 2024-04-26 19:12:53 +02:00
Girish Ramakrishnan 23e20b9b83 waitfordns: better debugs 2024-04-26 14:46:01 +02:00
Girish Ramakrishnan f6e4f1aefc network: ipv4 can be disabled 2024-04-25 15:50:42 +02:00
Girish Ramakrishnan cae2bfbdc2 domains: add desec provider 2024-04-24 21:29:42 +02:00
Girish Ramakrishnan 8b0bcde7ec cloudflare: result is now null and not empty array 2024-04-01 17:58:40 +02:00
Girish Ramakrishnan d862f1f5b4 cloudflare: fix crash when result is null 2024-04-01 17:31:20 +02:00
Johannes Zellner 0dfadc5922 remove extra quotes on digitalocean DNS TXT records 2024-01-17 18:35:48 +01:00
Girish Ramakrishnan afe670b49c cloudflare: use response.text since json may not be valid 2024-01-16 12:34:18 +01:00
Girish Ramakrishnan 33a97d0e50 cloudflare: validate response fields 2024-01-12 14:52:24 +01:00
Girish Ramakrishnan ca31dc8d78 namecheap: fix TLD
continuation of 6cdb448f62
2024-01-09 09:44:24 +01:00
Girish Ramakrishnan 6cdb448f62 namecheap: pass the TLD correctly
this is safe because namecheap does not allow external domains to be hosted.
otherwise, we would have to use tldjs
2024-01-08 11:54:37 +01:00
Girish Ramakrishnan c842d02d6f namecheap: slow down requests for rate limit
https://www.namecheap.com/support/knowledgebase/article.aspx/9739/63/api-faq/#z
2024-01-07 22:01:42 +01:00
Girish Ramakrishnan 672b472359 hetzner: typo in error message 2023-12-27 20:41:34 +01:00
Girish Ramakrishnan 37ed87f9c1 route53: retry on rate limit
route53 has a limit of 5 req/sec/region - https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html#limits-api-requests

see https://forum.cloudron.io/topic/10656/improve-dns-updates-to-avoid-rate-limits/
2023-12-27 12:23:09 +01:00
Girish Ramakrishnan 759f3f29f0 hetzner: accomodate other nameservers 2023-12-05 18:13:34 +01:00
Girish Ramakrishnan be35926fd1 ovh: accomodate anycast.me servers 2023-12-05 14:04:16 +01:00