feat(api): 开发auth、login等接口,规范格式化

This commit is contained in:
R524809
2026-09-03 13:11:06 +08:00
parent 195b6d25e9
commit 037928c778
82 changed files with 9199 additions and 5236 deletions
+32 -7
View File
@@ -1,12 +1,37 @@
import { Controller, Get, Module } from '@nestjs/common';
import { Controller, Get, Inject, Module } from '@nestjs/common';
import type { Database } from '@atlas/database';
import { AuthModule } from './auth/auth.module.js';
import { ApiError } from './common/api-error.js';
import { AppConfigModule } from './config/app-config.module.js';
import { DATABASE, DatabaseModule } from './database/database.module.js';
import { SecurityModule } from './security/security.module.js';
@Controller('health')
@Controller()
class HealthController {
@Get()
check() {
return { status: 'ok', service: 'api' };
}
public constructor(@Inject(DATABASE) private readonly database: Database) {}
@Get('health')
check() {
return { status: 'ok', service: 'api' };
}
@Get('ready')
async ready() {
try {
await this.database.query('SELECT 1');
return { status: 'ready', service: 'api' };
} catch {
throw new ApiError(
503,
'DEPENDENCY_UNAVAILABLE',
'服务依赖暂不可用',
);
}
}
}
@Module({ controllers: [HealthController] })
@Module({
imports: [AppConfigModule, DatabaseModule, SecurityModule, AuthModule],
controllers: [HealthController],
})
export class AppModule {}