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

@Route("projects")
@Tags("Projects")
export class ProjectsController {
  @Get()
  public listProjects(
    @Request() request: ExRequest,
    @Query() orgId?: string,
  ): ProjectsEnvelope {
    return { projects: listProjects(getDatabase(request), orgId) };
  }
}
