Files
Synapsis/src/app/api/version/route.ts
T
Christomatt a3b158099d feat(admin): Add version API endpoint and refactor admin/moderation layouts
- Create new `/api/version` endpoint to retrieve git commit count and hash information
- Simplify admin page layout by removing unnecessary nested divs and card wrapper
- Refactor moderation page tab navigation with improved button styling using btn-sm and btn-primary classes
- Consolidate padding and styling in moderation page for cleaner component structure
- Add word-break and overflow-wrap styles to report content display for better text handling
- Improve responsive design by adding minWidth: 0 to flex containers in report cards
- Streamline conditional rendering in admin settings to reduce DOM nesting depth
2026-01-26 18:58:34 +01:00

35 lines
1.1 KiB
TypeScript

import { NextResponse } from 'next/server';
import { execSync } from 'child_process';
export async function GET() {
try {
// Get the total number of commits
const commitCount = execSync('git rev-list --count HEAD', {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'ignore'] // Ignore stderr
}).trim();
// Also get the short hash for reference
const commitHash = execSync('git rev-parse --short HEAD', {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'ignore']
}).trim();
return NextResponse.json({
count: parseInt(commitCount, 10),
hash: commitHash,
fullHash: execSync('git rev-parse HEAD', {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'ignore']
}).trim()
});
} catch (error) {
// If git is not available or not a git repo, return unknown
return NextResponse.json({
count: null,
hash: 'unknown',
fullHash: null
});
}
}