feat(ux-37): add /api/version deployment metadata endpoint and CI verification gate
Deploy Canina / deploy (push) Successful in 2m9s
Deploy Canina / deploy (push) Successful in 2m9s
This commit is contained in:
1 parent
961bb383db
commit
87bf867513
2 files changed
+52
No files matched your search
@@ -0,0 +1,33 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const commitSha =
|
||||||
|
process.env.NEXT_PUBLIC_GIT_COMMIT ||
|
||||||
|
process.env.GIT_COMMIT_SHA ||
|
||||||
|
process.env.COMMIT_SHA ||
|
||||||
|
'local-build';
|
||||||
|
|
||||||
|
const buildTime =
|
||||||
|
process.env.BUILD_TIMESTAMP ||
|
||||||
|
process.env.NEXT_PUBLIC_BUILD_TIME ||
|
||||||
|
new Date().toISOString();
|
||||||
|
|
||||||
|
const environment = process.env.NODE_ENV || 'production';
|
||||||
|
const service = 'frontend';
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 'ok',
|
||||||
|
service,
|
||||||
|
commitSha,
|
||||||
|
buildTime,
|
||||||
|
environment,
|
||||||
|
}, {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
'Cache-Control': 'no-store, no-cache, must-revalidate',
|
||||||
|
'X-Commit-Sha': commitSha,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { GET } from './route';
|
||||||
|
|
||||||
|
describe('Deployment Metadata Endpoint Gate (UX-37)', () => {
|
||||||
|
it('returns valid deployment signature, status and commit header', async () => {
|
||||||
|
const response = await GET();
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
expect(data.status).toBe('ok');
|
||||||
|
expect(data.service).toBe('frontend');
|
||||||
|
expect(data).toHaveProperty('commitSha');
|
||||||
|
expect(data).toHaveProperty('buildTime');
|
||||||
|
expect(data).toHaveProperty('environment');
|
||||||
|
|
||||||
|
expect(response.headers.get('Cache-Control')).toBe('no-store, no-cache, must-revalidate');
|
||||||
|
expect(response.headers.get('X-Commit-Sha')).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user