// apps/server/src/auth/auth.controller.ts
import { Controller, Get, Query } from '@nestjs/common';
import { AuthService } from './auth.service';
import { ApiResponse } from '@nest-pure/shared';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get('login-url')
  getLoginUrl(): ApiResponse<string> {
    return {
      code: 0,
      data: this.authService.getSigninUrl(),
      message: 'success',
    };
  }

  @Get('callback')
  async callback(@Query('code') code: string): ApiResponse {
    const user = await this.authService.handleCallback(code);
    return {
      code: 0,
      data: user,
      message: 'login success',
    };
  }
}

