create-dp-koa 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/index.mjs +97 -0
- package/package.json +33 -0
- package/template/.env.development +9 -0
- package/template/.env.production +12 -0
- package/template/.github/workflows/ci-cd.yml +182 -0
- package/template/.trae/documents/controller_development_plan.md +386 -0
- package/template/.trae/skills/00-backend-core.skill.md +50 -0
- package/template/.trae/skills/01-backend-skill-router.skill.md +55 -0
- package/template/.trae/skills/10-backend-api.skill.md +54 -0
- package/template/.trae/skills/11-backend-controller-recipes.skill.md +107 -0
- package/template/.trae/skills/20-backend-repository.skill.md +25 -0
- package/template/.trae/skills/21-backend-service.skill.md +135 -0
- package/template/.trae/skills/25-backend-comments-and-doc.skill.md +97 -0
- package/template/.trae/skills/30-backend-validation.skill.md +320 -0
- package/template/.trae/skills/40-backend-error-logging.skill.md +21 -0
- package/template/.trae/skills/50-backend-bootstrap-lifecycle.skill.md +90 -0
- package/template/.trae/skills/60-backend-router-registration.skill.md +71 -0
- package/template/.trae/skills/70-backend-middleware.skill.md +98 -0
- package/template/.trae/skills/80-backend-utils-and-libs.skill.md +90 -0
- package/template/.trae/skills/85-backend-plugins.rule.md +64 -0
- package/template/.trae/skills/90-backend-testing.skill.md +29 -0
- package/template/.trae/skills/README.md +49 -0
- package/template/.vscode/launch.json +38 -0
- package/template/.vscode/settings.json +1 -0
- package/template/Dockerfile +36 -0
- package/template/README.md +229 -0
- package/template/docker-compose.yml +135 -0
- package/template/docs/API_DOCUMENTATION.md +837 -0
- package/template/docs/ARCHITECTURE_REFACTOR.md +109 -0
- package/template/docs/CACHE_MIGRATION_GUIDE.md +142 -0
- package/template/docs/DEPLOYMENT_GUIDE.md +1062 -0
- package/template/docs/DEVELOPMENT_GUIDE.md +1097 -0
- package/template/docs/DOCUMENTATION_CLEANUP_REPORT.md +166 -0
- package/template/docs/DOCUMENTATION_COMPLETION_REPORT.md +223 -0
- package/template/docs/DOCUMENTATION_INDEX.md +294 -0
- package/template/docs/DOCUMENTATION_STRUCTURE.md +221 -0
- package/template/docs/ENTERPRISE_ANNOTATION_SYSTEM_GUIDE.md +2069 -0
- package/template/docs/ENTERPRISE_DATABASE_ARCHITECTURE.md +318 -0
- package/template/docs/ENTERPRISE_DEPLOYMENT_GUIDE.md +547 -0
- package/template/docs/ENTERPRISE_ERROR_HANDLING_GUIDE.md +357 -0
- package/template/docs/ENTERPRISE_LOGGING_SYSTEM_GUIDE.md +494 -0
- package/template/docs/ENVIRONMENT_CONFIG_EXAMPLE.md +69 -0
- package/template/docs/FINAL_IMPLEMENTATION_SUMMARY.md +206 -0
- package/template/docs/HEALTH_CHECK_ROUTE_FIX.md +134 -0
- package/template/docs/IMPLEMENTATION_CHECKLIST.md +204 -0
- package/template/docs/INSTALLATION_GUIDE.md +611 -0
- package/template/docs/INTERCEPTOR_TESTING_REPORT.md +226 -0
- package/template/docs/INTERCEPTOR_TESTING_SCRIPTS.md +143 -0
- package/template/docs/LOGGING_OPTIMIZATION_GUIDE.md +126 -0
- package/template/docs/MEMORY_DATABASE_GUIDE.md +212 -0
- package/template/docs/NEW_ROUTER_INTEGRATION_GUIDE.md +345 -0
- package/template/docs/NEW_ROUTER_INTEGRATION_SUMMARY.md +259 -0
- package/template/docs/NEW_ROUTER_USAGE_GUIDE.md +364 -0
- package/template/docs/QUICK_START.md +268 -0
- package/template/docs/ROUTE_SLASH_COMPATIBILITY_FIX.md +191 -0
- package/template/docs/SERVICE_INTERCEPTOR_GUIDE.md +243 -0
- package/template/docs/SERVICE_LAYER_INDEX.md +205 -0
- package/template/docs/SERVICE_PATTERN_GUIDE.md +270 -0
- package/template/docs/SERVICE_RETURN_VALUE_SPECIFICATION.md +466 -0
- package/template/docs/SWAGGER_DEBUG_MODE_GUIDE.md +80 -0
- package/template/docs/SWAGGER_INTEGRATION_GUIDE.md +416 -0
- package/template/docs/TRANSACTION_MANAGER_USAGE.md +360 -0
- package/template/docs/TROUBLESHOOTING.md +869 -0
- package/template/env.production.example +62 -0
- package/template/jest.config.js +34 -0
- package/template/package-lock.json +13240 -0
- package/template/package.json +119 -0
- package/template/patches/typeorm+0.3.25.patch +22 -0
- package/template/scripts/sync-template.mjs +84 -0
- package/template/scripts/test-annotation-system.sh +48 -0
- package/template/scripts/test-core-functionality.sh +28 -0
- package/template/src/annotations/decorators/ConfigManagement.ts +9 -0
- package/template/src/annotations/decorators/DistributedTracing.ts +9 -0
- package/template/src/annotations/decorators/EnterprisePerformance.ts +9 -0
- package/template/src/annotations/decorators/PerformanceMonitor.ts +32 -0
- package/template/src/annotations/decorators/SecurityAudit.ts +9 -0
- package/template/src/annotations/index.ts +50 -0
- package/template/src/annotations/processors/ConfigManagementProcessor.ts +369 -0
- package/template/src/annotations/processors/DistributedTracingProcessor.ts +288 -0
- package/template/src/annotations/processors/EnterprisePerformanceProcessor.ts +189 -0
- package/template/src/annotations/processors/PerformanceMonitorProcessor.ts +101 -0
- package/template/src/annotations/processors/SecurityAuditProcessor.ts +345 -0
- package/template/src/annotations/processors/SwaggerProcessor.ts +612 -0
- package/template/src/annotations/processors/index.ts +10 -0
- package/template/src/app.ts +123 -0
- package/template/src/controllers/base.controller.ts +41 -0
- package/template/src/controllers/cacheManagement.controller.ts +131 -0
- package/template/src/controllers/captcha.controller.ts +57 -0
- package/template/src/controllers/demo/AnnotationDemoController.ts +118 -0
- package/template/src/controllers/example/EnterpriseExampleController.ts +297 -0
- package/template/src/controllers/example/ExampleController.ts +110 -0
- package/template/src/controllers/example/NewAnnotationExampleController.ts +159 -0
- package/template/src/controllers/example/SwaggerExampleController.ts +205 -0
- package/template/src/controllers/example/TransactionExample.controller.ts +336 -0
- package/template/src/controllers/health.controller.ts +235 -0
- package/template/src/controllers/home/register.controller.ts +58 -0
- package/template/src/controllers/home/ytGoods.controller.ts +92 -0
- package/template/src/controllers/home/ytShop.controller.ts +135 -0
- package/template/src/controllers/home/ytUser.controller.ts +89 -0
- package/template/src/controllers/logManagement.controller.ts +396 -0
- package/template/src/controllers/public/emailSend.controller.ts +65 -0
- package/template/src/controllers/public/ytUserAuth.controller.ts +174 -0
- package/template/src/controllers/testData.controller.ts +253 -0
- package/template/src/dto/controller/example/NewAnnotationExampleController.dto.ts +73 -0
- package/template/src/dto/controller/home/emailSend.controller.dto.ts +40 -0
- package/template/src/dto/controller/home/register.controller.dto.ts +45 -0
- package/template/src/dto/controller/home/ytGoods.controller.dto.ts +55 -0
- package/template/src/dto/controller/home/ytShop.controller.dto.ts +69 -0
- package/template/src/dto/controller/home/ytUser.controller.dto.ts +44 -0
- package/template/src/dto/controller/public/ytUserAuth.controller.dto.ts +63 -0
- package/template/src/dto/goods.dto.ts +212 -0
- package/template/src/dto/service/ytService.dto.ts +13 -0
- package/template/src/dto/user.dto.ts +177 -0
- package/template/src/entity/base.entity.ts +13 -0
- package/template/src/entity/columnTypes.ts +13 -0
- package/template/src/entity/goodsImagesUnlockKey.entity.ts +33 -0
- package/template/src/entity/goodsUnlocker.entity.ts +34 -0
- package/template/src/entity/index.ts +15 -0
- package/template/src/entity/shop.entity.ts +52 -0
- package/template/src/entity/shopUser.entity.ts +41 -0
- package/template/src/entity/ytGoods.entity.ts +94 -0
- package/template/src/entity/ytUser.entity.ts +96 -0
- package/template/src/examples/InterceptorExampleRunner.ts +284 -0
- package/template/src/examples/ServiceInterceptorExample.ts +214 -0
- package/template/src/examples/SwaggerProcessorExample.ts +169 -0
- package/template/src/examples/TransactionManagerDemo.ts +377 -0
- package/template/src/examples/cacheExamples.ts +155 -0
- package/template/src/framework/decorator/controller.ts +311 -0
- package/template/src/framework/decorator/processor/AnnotationDecorators.ts +100 -0
- package/template/src/framework/decorator/processor/AnnotationProcessor.ts +156 -0
- package/template/src/framework/decorator/processor/AnnotationProcessorConfig.ts +45 -0
- package/template/src/framework/decorator/processor/AnnotationRegistry.ts +117 -0
- package/template/src/framework/decorator/processor/AnnotationSystemInitializer.ts +95 -0
- package/template/src/framework/decorator/processor/ProcessorManager.ts +76 -0
- package/template/src/framework/decorator/processor/processors/CustomProcessors.ts +126 -0
- package/template/src/framework/decorator/processor/processors/DefaultProcessors.ts +207 -0
- package/template/src/framework/decorator/refactored/DecoratorFactory.ts +99 -0
- package/template/src/framework/decorator/refactored/DecoratorMetadataManager.ts +125 -0
- package/template/src/framework/decorator/refactored/DecoratorValidator.ts +128 -0
- package/template/src/framework/decorator/refactored/TypeSafeDecorators.ts +139 -0
- package/template/src/framework/decorator/refactored/index.ts +98 -0
- package/template/src/framework/decorator/swagger.ts +150 -0
- package/template/src/framework/interceptors/AdvancedServiceCallInterceptor.ts +375 -0
- package/template/src/framework/interceptors/ServiceCallInterceptor.ts +348 -0
- package/template/src/framework/interceptors/index.ts +19 -0
- package/template/src/framework/plugins/registry.ts +63 -0
- package/template/src/framework/plugins/types.ts +15 -0
- package/template/src/framework/types/ServiceResult.ts +151 -0
- package/template/src/framework/types/index.ts +16 -0
- package/template/src/framework/utils/CacheManager.ts +430 -0
- package/template/src/framework/utils/CacheService.ts +248 -0
- package/template/src/framework/utils/DtoValidator.ts +164 -0
- package/template/src/framework/utils/MigrationHelper.ts +179 -0
- package/template/src/framework/utils/MigrationManager.ts +256 -0
- package/template/src/framework/utils/NewRouter.ts +207 -0
- package/template/src/framework/utils/TransactionManager.ts +172 -0
- package/template/src/framework/utils/bootstrap.ts +445 -0
- package/template/src/framework/utils/cache.ts +269 -0
- package/template/src/framework/utils/databaseConfig.ts +148 -0
- package/template/src/framework/utils/db.ts +39 -0
- package/template/src/framework/utils/dbMonitor.ts +106 -0
- package/template/src/framework/utils/dynamicSwagger.ts +410 -0
- package/template/src/framework/utils/function.ts +61 -0
- package/template/src/framework/utils/gracefulShutdown.ts +131 -0
- package/template/src/framework/utils/logger.ts +388 -0
- package/template/src/framework/utils/metrics.ts +182 -0
- package/template/src/framework/utils/router.ts +417 -0
- package/template/src/framework/utils/swagger.ts +184 -0
- package/template/src/framework/utils/testDb.ts +19 -0
- package/template/src/framework/utils/token.ts +23 -0
- package/template/src/framework/utils/transform.ts +17 -0
- package/template/src/libs/aokEmailSender.ts +42 -0
- package/template/src/libs/captcha.ts +37 -0
- package/template/src/libs/cos.ts +45 -0
- package/template/src/libs/mCache.ts +7 -0
- package/template/src/libs/serviceValidate.ts +3 -0
- package/template/src/libs/tecentSms.ts +51 -0
- package/template/src/middlewares/a.middleware.ts +6 -0
- package/template/src/middlewares/error.middleware.ts +14 -0
- package/template/src/middlewares/logging.middleware.ts +187 -0
- package/template/src/middlewares/static.middleware.ts +79 -0
- package/template/src/middlewares/swagger.middleware.ts +70 -0
- package/template/src/middlewares/token.middleware.ts +32 -0
- package/template/src/migrations/1700000000000-InitialDatabaseStructure.ts +172 -0
- package/template/src/migrations/index.ts +6 -0
- package/template/src/plugins/weboffice/core/context.ts +47 -0
- package/template/src/plugins/weboffice/core/errors.ts +51 -0
- package/template/src/plugins/weboffice/core/types.ts +63 -0
- package/template/src/plugins/weboffice/core/utils.ts +7 -0
- package/template/src/plugins/weboffice/entities/index.ts +3 -0
- package/template/src/plugins/weboffice/entities/webofficeFile.entity.ts +28 -0
- package/template/src/plugins/weboffice/entities/webofficeFileVersion.entity.ts +29 -0
- package/template/src/plugins/weboffice/http/routes.ts +179 -0
- package/template/src/plugins/weboffice/index.ts +23 -0
- package/template/src/plugins/weboffice/services/webofficeCallback.service.ts +274 -0
- package/template/src/repository/UserRepository.ts +122 -0
- package/template/src/repository/base/BaseRepository.ts +124 -0
- package/template/src/repository/interfaces/IBaseRepository.ts +67 -0
- package/template/src/routers/index.ts +49 -0
- package/template/src/service/base.service.ts +116 -0
- package/template/src/service/paramValidateTest.service.ts +139 -0
- package/template/src/service/ytGoods.service.ts +42 -0
- package/template/src/service/ytShop.service.ts +90 -0
- package/template/src/service/ytUser.service.ts +451 -0
- package/template/src/test/swaggerParameterTest.ts +90 -0
- package/template/src/utils/testDataInitializer.ts +296 -0
- package/template/static/output.json +15203 -0
- package/template/test/controllers/controllers.test.ts +173 -0
- package/template/test/controllers/example/ExampleController.test.ts +222 -0
- package/template/test/controllers/example/NewAnnotationExampleController.test.ts +200 -0
- package/template/test/framework/TransactionManagerDemo.test.ts +363 -0
- package/template/test/framework/annotation/AnnotationDecorators.test.ts +222 -0
- package/template/test/framework/annotation/AnnotationExecutor.test.ts +246 -0
- package/template/test/framework/annotation/AnnotationProcessor.test.ts +179 -0
- package/template/test/framework/annotation/CustomProcessors.test.ts +313 -0
- package/template/test/framework/annotation/DefaultProcessors.test.ts +371 -0
- package/template/test/framework/annotation/NewRouter.test.ts +272 -0
- package/template/test/framework/annotation/ProcessorManager.test.ts +248 -0
- package/template/test/framework/annotation/setup.ts +26 -0
- package/template/test/framework/cache.test.ts +101 -0
- package/template/test/framework/databaseConfig.test.ts +142 -0
- package/template/test/integration/integration.test.ts +153 -0
- package/template/test/plugins/weboffice/http.routes.int.test.ts +61 -0
- package/template/test/service/business.test.ts +87 -0
- package/template/test/service/paramValidateTest.service.test.ts +184 -0
- package/template/test/service/ytUser.service.test.ts +566 -0
- package/template/test/setup.ts +20 -0
- package/template/test/setupAfterEnv.ts +14 -0
- package/template/test/utils/testHelpers.ts +220 -0
- package/template/test_output.txt +0 -0
- package/template/tsconfig.build.json +17 -0
- package/template/tsconfig.json +31 -0
- package/template/webpack.config.js +71 -0
- package/template/yarn.lock +7354 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# DP-Koa Framework
|
|
2
|
+
|
|
3
|
+
一个基于 Koa.js 的企业级 Node.js 框架,提供完整的后端开发解决方案。
|
|
4
|
+
|
|
5
|
+
## 📋 目录
|
|
6
|
+
|
|
7
|
+
- [快速开始](#快速开始)
|
|
8
|
+
- [项目特性](#项目特性)
|
|
9
|
+
- [文档导航](#文档导航)
|
|
10
|
+
- [技术栈](#技术栈)
|
|
11
|
+
- [系统要求](#系统要求)
|
|
12
|
+
- [安装与配置](#安装与配置)
|
|
13
|
+
- [开发指南](#开发指南)
|
|
14
|
+
- [API 文档](#api-文档)
|
|
15
|
+
- [部署指南](#部署指南)
|
|
16
|
+
- [故障排除](#故障排除)
|
|
17
|
+
- [贡献指南](#贡献指南)
|
|
18
|
+
- [许可证](#许可证)
|
|
19
|
+
|
|
20
|
+
## 🚀 快速开始
|
|
21
|
+
|
|
22
|
+
### 环境要求
|
|
23
|
+
|
|
24
|
+
- Node.js >= 18.0.0
|
|
25
|
+
- npm >= 8.0.0
|
|
26
|
+
- MySQL >= 8.0 或 SQLite3
|
|
27
|
+
- Redis (可选,用于缓存)
|
|
28
|
+
|
|
29
|
+
### 一键启动
|
|
30
|
+
|
|
31
|
+
#### 使用 npm 脚手架(推荐)
|
|
32
|
+
|
|
33
|
+
从 npm 安装官方模板并生成新项目(需已安装 Node.js 与 npm):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm create dp-koa@latest
|
|
37
|
+
# 或指定目录名:npx create-dp-koa@latest my-app
|
|
38
|
+
cd my-app
|
|
39
|
+
|
|
40
|
+
npm install
|
|
41
|
+
cp env.production.example .env
|
|
42
|
+
npm run dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
将 `my-app` 换为你创建时使用的目录名。
|
|
46
|
+
|
|
47
|
+
#### 克隆源码仓库
|
|
48
|
+
|
|
49
|
+
框架源码托管在 Gitee,**克隆请使用 SSH**:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone git@gitee.com:rajan_admin/dp-koa-framework.git
|
|
53
|
+
cd dp-koa-framework
|
|
54
|
+
|
|
55
|
+
npm install
|
|
56
|
+
cp env.production.example .env
|
|
57
|
+
npm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
未配置 SSH 时,可在 Gitee 网页复制 HTTPS 地址作为备用。
|
|
61
|
+
|
|
62
|
+
访问 `http://localhost:3000` 查看应用运行状态。
|
|
63
|
+
|
|
64
|
+
#### 维护者:发布脚手架新版本
|
|
65
|
+
|
|
66
|
+
在推送代码到远程后,于仓库根目录更新模板并发布 `packages/create-dp-koa`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run sync:create-template
|
|
70
|
+
cd packages/create-dp-koa
|
|
71
|
+
npm version patch # 或 minor / major
|
|
72
|
+
npm publish
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`npm publish` 前会执行 `prepublishOnly` 再次同步模板;若已手动执行 `sync:create-template`,保持版本与内容一致即可。
|
|
76
|
+
|
|
77
|
+
## ✨ 项目特性
|
|
78
|
+
|
|
79
|
+
### 🏗️ 核心架构
|
|
80
|
+
- **模块化设计**: 基于依赖注入的模块化架构
|
|
81
|
+
- **注解系统**: 强大的装饰器注解系统,简化开发
|
|
82
|
+
- **拦截器**: 灵活的请求/响应拦截机制
|
|
83
|
+
- **事务管理**: 完整的数据库事务支持
|
|
84
|
+
|
|
85
|
+
### 🛠️ 开发工具
|
|
86
|
+
- **TypeScript**: 完整的类型支持
|
|
87
|
+
- **Swagger**: 自动生成 API 文档
|
|
88
|
+
- **Jest**: 全面的测试覆盖
|
|
89
|
+
- **ESLint**: 代码质量检查
|
|
90
|
+
|
|
91
|
+
### 🔒 企业级特性
|
|
92
|
+
- **安全认证**: JWT + bcrypt 安全认证
|
|
93
|
+
- **日志系统**: 结构化日志记录
|
|
94
|
+
- **缓存管理**: 多级缓存策略
|
|
95
|
+
- **监控告警**: 性能监控和健康检查
|
|
96
|
+
|
|
97
|
+
### 🚀 部署支持
|
|
98
|
+
- **Docker**: 容器化部署
|
|
99
|
+
- **Docker Compose**: 多服务编排
|
|
100
|
+
- **Nginx**: 负载均衡和反向代理
|
|
101
|
+
- **监控**: Prometheus + Grafana
|
|
102
|
+
|
|
103
|
+
## 📚 文档导航
|
|
104
|
+
|
|
105
|
+
### 📖 文档索引
|
|
106
|
+
- [📋 文档索引](docs/DOCUMENTATION_INDEX.md) - 完整文档导航
|
|
107
|
+
- [📁 文档结构](docs/DOCUMENTATION_STRUCTURE.md) - 文档体系说明
|
|
108
|
+
|
|
109
|
+
### 🚀 快速开始
|
|
110
|
+
- [⚡ 快速开始指南](docs/QUICK_START.md) - 5分钟快速上手
|
|
111
|
+
- [🔧 安装配置指南](docs/INSTALLATION_GUIDE.md) - 详细安装步骤
|
|
112
|
+
- [⚙️ 环境配置说明](docs/ENVIRONMENT_CONFIG_EXAMPLE.md) - 环境变量配置
|
|
113
|
+
|
|
114
|
+
### 💻 开发文档
|
|
115
|
+
- [👨💻 开发指南](docs/DEVELOPMENT_GUIDE.md) - 开发规范和最佳实践
|
|
116
|
+
- [📖 API 文档](docs/API_DOCUMENTATION.md) - 完整的 API 参考
|
|
117
|
+
- [🎯 注解系统指南](docs/ENTERPRISE_ANNOTATION_SYSTEM_GUIDE.md) - 注解使用说明
|
|
118
|
+
- [🏗️ 服务层指南](docs/SERVICE_PATTERN_GUIDE.md) - 服务层设计模式
|
|
119
|
+
|
|
120
|
+
### 🏛️ 架构文档
|
|
121
|
+
- [🗄️ 数据库架构](docs/ENTERPRISE_DATABASE_ARCHITECTURE.md) - 数据库设计
|
|
122
|
+
- [🔄 拦截器指南](docs/SERVICE_INTERCEPTOR_GUIDE.md) - 拦截器使用
|
|
123
|
+
- [💾 事务管理](docs/TRANSACTION_MANAGER_USAGE.md) - 事务处理
|
|
124
|
+
- [📊 日志系统](docs/ENTERPRISE_LOGGING_SYSTEM_GUIDE.md) - 日志配置
|
|
125
|
+
|
|
126
|
+
### 🚀 部署文档
|
|
127
|
+
- [☁️ 部署指南](docs/DEPLOYMENT_GUIDE.md) - 生产环境部署
|
|
128
|
+
- [🐳 企业级部署](docs/ENTERPRISE_DEPLOYMENT_GUIDE.md) - 企业级部署方案
|
|
129
|
+
- [📈 监控配置](docs/DEPLOYMENT_GUIDE.md#监控配置) - 监控系统配置
|
|
130
|
+
|
|
131
|
+
### 🧪 测试文档
|
|
132
|
+
- [🔬 测试指南](docs/TESTING_GUIDE.md) - 测试策略和工具
|
|
133
|
+
- [📋 拦截器测试](docs/INTERCEPTOR_TESTING_REPORT.md) - 拦截器测试报告
|
|
134
|
+
|
|
135
|
+
### 🆘 故障排除
|
|
136
|
+
- [🔍 故障排除指南](docs/TROUBLESHOOTING.md) - 常见问题解决
|
|
137
|
+
- [⚠️ 错误处理指南](docs/ENTERPRISE_ERROR_HANDLING_GUIDE.md) - 错误处理策略
|
|
138
|
+
|
|
139
|
+
## 🛠️ 技术栈
|
|
140
|
+
|
|
141
|
+
### 后端框架
|
|
142
|
+
- **Koa.js**: 轻量级 Web 框架
|
|
143
|
+
- **TypeScript**: 类型安全的 JavaScript
|
|
144
|
+
- **TypeORM**: 对象关系映射
|
|
145
|
+
|
|
146
|
+
### 数据库
|
|
147
|
+
- **MySQL**: 主数据库
|
|
148
|
+
- **SQLite**: 开发/测试数据库
|
|
149
|
+
- **Redis**: 缓存和会话存储
|
|
150
|
+
|
|
151
|
+
### 开发工具
|
|
152
|
+
- **Jest**: 测试框架
|
|
153
|
+
- **ESLint**: 代码检查
|
|
154
|
+
- **Webpack**: 模块打包
|
|
155
|
+
- **Swagger**: API 文档
|
|
156
|
+
|
|
157
|
+
### 部署工具
|
|
158
|
+
- **Docker**: 容器化
|
|
159
|
+
- **Nginx**: Web 服务器
|
|
160
|
+
- **Prometheus**: 监控
|
|
161
|
+
- **Grafana**: 可视化
|
|
162
|
+
|
|
163
|
+
## 📋 系统要求
|
|
164
|
+
|
|
165
|
+
### 开发环境
|
|
166
|
+
- Node.js 18.0.0+
|
|
167
|
+
- npm 8.0.0+
|
|
168
|
+
- MySQL 8.0+ 或 SQLite3
|
|
169
|
+
- Git
|
|
170
|
+
|
|
171
|
+
### 生产环境
|
|
172
|
+
- Node.js 18.0.0+
|
|
173
|
+
- MySQL 8.0+
|
|
174
|
+
- Redis 6.0+
|
|
175
|
+
- Docker 20.0+
|
|
176
|
+
- Nginx 1.18+
|
|
177
|
+
|
|
178
|
+
## 🔧 安装与配置
|
|
179
|
+
|
|
180
|
+
详细的安装和配置步骤请参考:
|
|
181
|
+
- [安装配置指南](docs/INSTALLATION_GUIDE.md)
|
|
182
|
+
- [环境配置说明](docs/ENVIRONMENT_CONFIG_EXAMPLE.md)
|
|
183
|
+
|
|
184
|
+
## 💻 开发指南
|
|
185
|
+
|
|
186
|
+
开发相关文档:
|
|
187
|
+
- [开发指南](docs/DEVELOPMENT_GUIDE.md)
|
|
188
|
+
- [注解系统指南](docs/ENTERPRISE_ANNOTATION_SYSTEM_GUIDE.md)
|
|
189
|
+
- [服务层指南](docs/SERVICE_PATTERN_GUIDE.md)
|
|
190
|
+
|
|
191
|
+
## 📖 API 文档
|
|
192
|
+
|
|
193
|
+
API 相关文档:
|
|
194
|
+
- [API 文档](docs/API_DOCUMENTATION.md)
|
|
195
|
+
- [Swagger 集成指南](docs/SWAGGER_INTEGRATION_GUIDE.md)
|
|
196
|
+
|
|
197
|
+
## 🚀 部署指南
|
|
198
|
+
|
|
199
|
+
部署相关文档:
|
|
200
|
+
- [部署指南](docs/ENTERPRISE_DEPLOYMENT_GUIDE.md)
|
|
201
|
+
- [Docker 部署](docs/DOCKER_DEPLOYMENT.md)
|
|
202
|
+
|
|
203
|
+
## 🔍 故障排除
|
|
204
|
+
|
|
205
|
+
遇到问题?查看:
|
|
206
|
+
- [故障排除指南](docs/TROUBLESHOOTING.md)
|
|
207
|
+
- [错误处理指南](docs/ENTERPRISE_ERROR_HANDLING_GUIDE.md)
|
|
208
|
+
|
|
209
|
+
## 🤝 贡献指南
|
|
210
|
+
|
|
211
|
+
欢迎贡献代码!请查看:
|
|
212
|
+
- [贡献指南](docs/CONTRIBUTING.md)
|
|
213
|
+
- [代码规范](docs/CODE_STANDARDS.md)
|
|
214
|
+
|
|
215
|
+
## 📄 许可证
|
|
216
|
+
|
|
217
|
+
本项目采用 ISC 许可证。详情请查看 [LICENSE](LICENSE) 文件。
|
|
218
|
+
|
|
219
|
+
## 📞 支持
|
|
220
|
+
|
|
221
|
+
- 📧 邮箱: support@example.com
|
|
222
|
+
- 🐛 问题反馈: [GitHub Issues](https://github.com/your-repo/issues)
|
|
223
|
+
- 📖 文档: [在线文档](https://your-docs-site.com)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
**快速链接**:
|
|
228
|
+
- [快速开始](docs/QUICK_START.md) | [安装指南](docs/INSTALLATION_GUIDE.md) | [开发指南](docs/DEVELOPMENT_GUIDE.md)
|
|
229
|
+
- [API 文档](docs/API_DOCUMENTATION.md) | [部署指南](docs/ENTERPRISE_DEPLOYMENT_GUIDE.md) | [故障排除](docs/TROUBLESHOOTING.md)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Docker Compose配置 - 企业级应用部署
|
|
2
|
+
|
|
3
|
+
version: '3.8'
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# 主应用服务
|
|
7
|
+
app:
|
|
8
|
+
build: .
|
|
9
|
+
ports:
|
|
10
|
+
- "3000:3000"
|
|
11
|
+
environment:
|
|
12
|
+
- NODE_ENV=production
|
|
13
|
+
- PORT=3000
|
|
14
|
+
- DB_HOST=mysql
|
|
15
|
+
- DB_PORT=3306
|
|
16
|
+
- DB_USERNAME=app_user
|
|
17
|
+
- DB_PASSWORD=app_password
|
|
18
|
+
- DB_DATABASE=app_db
|
|
19
|
+
depends_on:
|
|
20
|
+
mysql:
|
|
21
|
+
condition: service_healthy
|
|
22
|
+
redis:
|
|
23
|
+
condition: service_started
|
|
24
|
+
restart: unless-stopped
|
|
25
|
+
networks:
|
|
26
|
+
- app-network
|
|
27
|
+
volumes:
|
|
28
|
+
- ./logs:/app/logs
|
|
29
|
+
healthcheck:
|
|
30
|
+
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
|
31
|
+
interval: 30s
|
|
32
|
+
timeout: 10s
|
|
33
|
+
retries: 3
|
|
34
|
+
start_period: 40s
|
|
35
|
+
|
|
36
|
+
# MySQL数据库
|
|
37
|
+
mysql:
|
|
38
|
+
image: mysql:8.0
|
|
39
|
+
environment:
|
|
40
|
+
- MYSQL_ROOT_PASSWORD=root_password
|
|
41
|
+
- MYSQL_DATABASE=app_db
|
|
42
|
+
- MYSQL_USER=app_user
|
|
43
|
+
- MYSQL_PASSWORD=app_password
|
|
44
|
+
ports:
|
|
45
|
+
- "3306:3306"
|
|
46
|
+
volumes:
|
|
47
|
+
- mysql_data:/var/lib/mysql
|
|
48
|
+
- ./docker/mysql/init:/docker-entrypoint-initdb.d
|
|
49
|
+
restart: unless-stopped
|
|
50
|
+
networks:
|
|
51
|
+
- app-network
|
|
52
|
+
healthcheck:
|
|
53
|
+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
54
|
+
interval: 10s
|
|
55
|
+
timeout: 5s
|
|
56
|
+
retries: 5
|
|
57
|
+
start_period: 30s
|
|
58
|
+
|
|
59
|
+
# Redis缓存
|
|
60
|
+
redis:
|
|
61
|
+
image: redis:7-alpine
|
|
62
|
+
ports:
|
|
63
|
+
- "6379:6379"
|
|
64
|
+
volumes:
|
|
65
|
+
- redis_data:/data
|
|
66
|
+
restart: unless-stopped
|
|
67
|
+
networks:
|
|
68
|
+
- app-network
|
|
69
|
+
command: redis-server --appendonly yes --requirepass redis_password
|
|
70
|
+
healthcheck:
|
|
71
|
+
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
|
72
|
+
interval: 10s
|
|
73
|
+
timeout: 3s
|
|
74
|
+
retries: 5
|
|
75
|
+
|
|
76
|
+
# Nginx负载均衡器
|
|
77
|
+
nginx:
|
|
78
|
+
image: nginx:alpine
|
|
79
|
+
ports:
|
|
80
|
+
- "80:80"
|
|
81
|
+
- "443:443"
|
|
82
|
+
volumes:
|
|
83
|
+
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
|
|
84
|
+
- ./docker/nginx/ssl:/etc/nginx/ssl
|
|
85
|
+
depends_on:
|
|
86
|
+
- app
|
|
87
|
+
restart: unless-stopped
|
|
88
|
+
networks:
|
|
89
|
+
- app-network
|
|
90
|
+
|
|
91
|
+
# Prometheus监控
|
|
92
|
+
prometheus:
|
|
93
|
+
image: prom/prometheus:latest
|
|
94
|
+
ports:
|
|
95
|
+
- "9090:9090"
|
|
96
|
+
volumes:
|
|
97
|
+
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
98
|
+
- prometheus_data:/prometheus
|
|
99
|
+
command:
|
|
100
|
+
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
101
|
+
- '--storage.tsdb.path=/prometheus'
|
|
102
|
+
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
103
|
+
- '--web.console.templates=/etc/prometheus/consoles'
|
|
104
|
+
- '--storage.tsdb.retention.time=200h'
|
|
105
|
+
- '--web.enable-lifecycle'
|
|
106
|
+
restart: unless-stopped
|
|
107
|
+
networks:
|
|
108
|
+
- app-network
|
|
109
|
+
|
|
110
|
+
# Grafana仪表板
|
|
111
|
+
grafana:
|
|
112
|
+
image: grafana/grafana:latest
|
|
113
|
+
ports:
|
|
114
|
+
- "3001:3000"
|
|
115
|
+
environment:
|
|
116
|
+
- GF_SECURITY_ADMIN_PASSWORD=admin_password
|
|
117
|
+
volumes:
|
|
118
|
+
- grafana_data:/var/lib/grafana
|
|
119
|
+
- ./docker/grafana/provisioning:/etc/grafana/provisioning
|
|
120
|
+
depends_on:
|
|
121
|
+
- prometheus
|
|
122
|
+
restart: unless-stopped
|
|
123
|
+
networks:
|
|
124
|
+
- app-network
|
|
125
|
+
|
|
126
|
+
volumes:
|
|
127
|
+
mysql_data:
|
|
128
|
+
redis_data:
|
|
129
|
+
prometheus_data:
|
|
130
|
+
grafana_data:
|
|
131
|
+
|
|
132
|
+
networks:
|
|
133
|
+
app-network:
|
|
134
|
+
driver: bridge
|
|
135
|
+
|