import { RedmineTypes } from '../models/redmine-types';
import { Controller, Get, Param } from '@nestjs/common';
import { UsersService } from './users.service';

@Controller('users')
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  @Get(':id')
  async getUser(@Param('id') id: number): Promise<RedmineTypes.PublicUser> {
    return await this.usersService.getUser(id);
  }

  @Get(':id/json')
  async getUserLikeRedmine(
    @Param('id') id: number,
  ): Promise<{ user: RedmineTypes.PublicUser }> {
    const user = await this.usersService.getUser(id);
    return {
      user: user,
    };
  }
}
