feat: upgrade to egg v4
BREAKING CHANGE: drop Node.js < 18.19.0 support
part of https://github.com/eggjs/egg/issues/3644
https://github.com/eggjs/egg/issues/5257
Summary by CodeRabbit
-
New Features
- Updated API endpoints: The root endpoint remains unchanged while the /foo endpoint now returns a JSON error response with status 400.
-
Documentation
- Revised documentation now reflects updated Node.js version requirements and features a new CI badge.
-
Chores
- Upgraded testing, dependency, and build configurations to improve performance and maintainability.
- Streamlined project structure with removal of deprecated templates and configurations.
- Introduced new TypeScript configuration files for enhanced project setup.
- Added new ESLint configuration for improved code quality.
Walkthrough
Repository examples are migrated to newer EggJS beta versions with Node.js 20+ requirement, CI workflows updated to matrix-based testing, and projects converted from CommonJS to ES modules with TypeScript enhancements.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
CI & Workflow Configuration .github/workflows/ci.yml, .github/PULL_REQUEST_TEMPLATE.md |
Workflow updated to matrix-based testing across ubuntu-latest/macos-latest with Node.js 20/22/24; removed workflow_dispatch trigger; added concurrency group; deleted PR template file. |
Documentation & Root Configuration README.md, package.json |
Replaced Travis CI badge with GitHub Actions; updated Node.js requirement from 8 to 20; updated test script to use bin/test.sh; updated npminstall from ^6.6.2 to ^7.12.0. |
Test Infrastructure bin/test.sh |
New Bash script added for running tests across example directories with npm update and cleanup. |
hello-tegg Example Migration hello-tegg/.gitignore, hello-tegg/config/config.default.ts, hello-tegg/package.json, hello-tegg/test/biz/HelloService.test.ts, hello-tegg/test/controller/HelloController.test.ts, hello-tegg/tsconfig.json, hello-tegg/tsconfig.prod.json, hello-tegg/app/biz/package.json, hello-tegg/app/controller/HelloController.ts, hello-tegg/app/middleware/trace_method.ts, hello-tegg/config/plugin.ts |
Migrated to EggJS beta packages; updated config to use defineConfigFactory; switched to @eggjs/mock/bootstrap; updated dependencies to Node 20+; converted imports to type-only where applicable; added .egg/ to gitignore; created tsconfig.prod.json. |
helloworld Example Migration helloworld/.eslintrc, helloworld/.gitignore, helloworld/app/controller/foo.js, helloworld/app/controller/foo.ts, helloworld/app/controller/home.js, helloworld/app/controller/home.ts, helloworld/app/router.ts, helloworld/config/config.default.js, helloworld/config/config.default.ts, helloworld/package.json, helloworld/test/index.test.js, helloworld/test/index.test.ts, helloworld/tsconfig.json |
Converted controllers from JavaScript to TypeScript; updated router to ES6 export; migrated config to defineConfig; added ESLint config and tsconfig; replaced CommonJS with ESM; updated package.json to beta dependencies and added build/lint/test scripts; updated tests to use @eggjs/mock/bootstrap; updated foo controller to return status 400 with JSON response. |
body-parser-example Migration body-parser-example/app/controller/home.js, body-parser-example/config/config.default.js, body-parser-example/package.json, body-parser-example/test/home.test.js |
Updated egg-bin/egg-mock to @eggjs versions (beta); changed project name to body-parser-example; removed 'use strict' directive; updated import from egg-mock/bootstrap to @eggjs/mock/bootstrap; renamed cov script to ci. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Rationale: Broad scope affecting multiple example directories with repetitive patterns (version updates, import migrations, ESM conversion). Changes are largely consistent and mechanical across projects—dependency updates, test framework migrations to @eggjs/mock, and TypeScript additions. However, logic density is low and patterns repeat, reducing per-file review complexity. Some heterogeneity in foo controller behavior change (status 400 vs. 200) and configuration factory pattern introduction warrants focused attention.
Poem
🐰 A rabbit hops through examples new, With beta packages and Node 20 too! From CommonJS to ES modules we spring, TypeScript configs and tests take wing— The warren's all modernized, what a thing! ✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The title "feat: upgrade to egg v4" clearly and directly summarizes the primary objective of this pull request. The changeset demonstrates a comprehensive upgrade to Egg v4 across the project, including updates to core dependencies (egg, @eggjs packages), minimum Node.js version requirement from 14.17.0 to >= 20, migration to new configuration patterns (defineConfigFactory, defineConfig), adoption of TypeScript with ES6 modules, and updates to tooling (ESLint 8, TypeScript 5, @types/node 22). The title is concise, specific, and avoids vague terminology, making it clear to developers reviewing the repository history what the primary change entails. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
egg-v4
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
No dependency changes detected. Learn more about Socket for GitHub.
👍 No dependency changes detected in pull request