UNPKG

@nerdo/code-reviewer

Version:

A web-based visual git diff tool for reviewing code changes between commits, branches, and tags

47 lines (46 loc) 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.commitRouter = void 0; const express_1 = require("express"); const GitCommitRepository_1 = require("../../infrastructure/git/GitCommitRepository"); exports.commitRouter = (0, express_1.Router)(); const commitRepository = new GitCommitRepository_1.GitCommitRepository(); exports.commitRouter.post('/list', async (req, res) => { try { const { path, branch, limit } = req.body; if (!path) { return res.status(400).json({ error: 'Repository path is required' }); } const commits = await commitRepository.getCommits(path, branch, limit); res.json(commits); } catch (error) { res.status(500).json({ error: error instanceof Error ? error.message : 'Unknown error' }); } }); exports.commitRouter.post('/single', async (req, res) => { try { const { path, hash } = req.body; if (!path || !hash) { return res.status(400).json({ error: 'Repository path and commit hash are required' }); } const commit = await commitRepository.getCommit(path, hash); res.json(commit); } catch (error) { res.status(500).json({ error: error instanceof Error ? error.message : 'Unknown error' }); } }); exports.commitRouter.post('/between', async (req, res) => { try { const { path, fromHash, toHash } = req.body; if (!path || !fromHash || !toHash) { return res.status(400).json({ error: 'Repository path, fromHash, and toHash are required' }); } const commits = await commitRepository.getCommitsBetween(path, fromHash, toHash); res.json(commits); } catch (error) { res.status(500).json({ error: error instanceof Error ? error.message : 'Unknown error' }); } });