import type { Request as ExRequest } from "express";
import { Get, Query, Request, Route, Tags } from "tsoa";
import { listUsers } from "../repository";
import type { UsersEnvelope } from "../models";
import { getDatabase } from "./shared";

@Route("users")
@Tags("Users")
export class UsersController {
  @Get()
  public listUsers(
    @Request() request: ExRequest,
    @Query() orgId?: string,
  ): UsersEnvelope {
    return { users: listUsers(getDatabase(request), orgId) };
  }
}
