Expose project revision timeline
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Request, Response } from "express";
|
||||
import { listProjectRevisionsQuerySchema } from "../../shared/validation/project-history.schemas.js";
|
||||
import { projectHistoryStore } from "../composition/project-command-stores.js";
|
||||
|
||||
export function getProjectHistory(req: Request, res: Response) {
|
||||
@@ -13,3 +14,23 @@ export function getProjectHistory(req: Request, res: Response) {
|
||||
}
|
||||
return res.json(state);
|
||||
}
|
||||
|
||||
export function listProjectRevisions(req: Request, res: Response) {
|
||||
const { projectId } = req.params;
|
||||
if (typeof projectId !== "string" || !projectId.trim()) {
|
||||
return res.status(400).json({ error: "Invalid projectId" });
|
||||
}
|
||||
const parsed = listProjectRevisionsQuerySchema.safeParse(req.query);
|
||||
if (!parsed.success) {
|
||||
return res.status(400).json({ error: parsed.error.flatten() });
|
||||
}
|
||||
|
||||
const page = projectHistoryStore.listRevisions({
|
||||
projectId,
|
||||
...parsed.data,
|
||||
});
|
||||
if (!page) {
|
||||
return res.status(404).json({ error: "Project not found" });
|
||||
}
|
||||
return res.json(page);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user