forked from datawhale/whale-town-end
refactor(auth): 重构认证模块架构 - 将Gateway层组件从Business层分离
范围:src/gateway/auth/, src/business/auth/, src/app.module.ts 涉及文件: - 新增:src/gateway/auth/ 目录及所有文件 - 移动:Controller、Guard、Decorator、DTO从business层移至gateway层 - 修改:src/business/auth/index.ts(移除Gateway层组件导出) - 修改:src/app.module.ts(使用AuthGatewayModule替代AuthModule) 主要改进: - 明确Gateway层和Business层的职责边界 - Controller、Guard、Decorator属于Gateway层职责 - Business层专注于业务逻辑和服务 - 符合分层架构设计原则
This commit is contained in:
52
src/gateway/auth/auth.gateway.module.ts
Normal file
52
src/gateway/auth/auth.gateway.module.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 认证网关模块
|
||||
*
|
||||
* 架构层级:Gateway Layer(网关层)
|
||||
*
|
||||
* 功能描述:
|
||||
* - 整合所有认证相关的网关组件
|
||||
* - 提供HTTP API接口
|
||||
* - 配置认证守卫和中间件
|
||||
* - 处理请求验证和响应格式化
|
||||
*
|
||||
* 职责分离:
|
||||
* - 专注于HTTP协议处理和API网关功能
|
||||
* - 依赖业务层服务,不包含业务逻辑
|
||||
* - 提供统一的API入口和文档
|
||||
*
|
||||
* 依赖关系:
|
||||
* - 依赖 Business Layer 的 AuthModule
|
||||
* - 提供 Controller 和 Guard
|
||||
*
|
||||
* @author moyin
|
||||
* @version 2.0.0
|
||||
* @since 2026-01-14
|
||||
* @lastModified 2026-01-14
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common';
|
||||
import { LoginController } from './login.controller';
|
||||
import { RegisterController } from './register.controller';
|
||||
import { JwtAuthGuard } from './jwt_auth.guard';
|
||||
import { AuthModule } from '../../business/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
// 导入业务层模块
|
||||
AuthModule,
|
||||
],
|
||||
controllers: [
|
||||
// 网关层控制器
|
||||
LoginController,
|
||||
RegisterController,
|
||||
],
|
||||
providers: [
|
||||
// 认证守卫
|
||||
JwtAuthGuard,
|
||||
],
|
||||
exports: [
|
||||
// 导出守卫供其他模块使用
|
||||
JwtAuthGuard,
|
||||
],
|
||||
})
|
||||
export class AuthGatewayModule {}
|
||||
Reference in New Issue
Block a user