19 lines
641 B
TypeScript
19 lines
641 B
TypeScript
import type { Request, Response } from "express";
|
|
import { db } from "../../db/client.js";
|
|
import { ProjectHistoryRepository } from "../../db/repositories/project-history.repository.js";
|
|
|
|
const projectHistoryRepository = new ProjectHistoryRepository(db);
|
|
|
|
export function getProjectHistory(req: Request, res: Response) {
|
|
const { projectId } = req.params;
|
|
if (typeof projectId !== "string") {
|
|
return res.status(400).json({ error: "Invalid projectId" });
|
|
}
|
|
|
|
const state = projectHistoryRepository.getState(projectId);
|
|
if (!state) {
|
|
return res.status(404).json({ error: "Project not found" });
|
|
}
|
|
return res.json(state);
|
|
}
|