From a417f23395137a3010c71553e525fca4afbce2f2 Mon Sep 17 00:00:00 2001 From: "agent-studio[bot]" Date: Tue, 5 May 2026 10:49:46 +0000 Subject: [PATCH] feat: Add a simple hello world API endpoint at /api/hello that returns { messa Generated by agent-studio SDLC pipeline run cmosi9gfl0003qm01kj7lavj8 --- .../results.json | 2 +- src/app/api/hello/route.ts | 13 ++++++++++ src/tests/api/hello.test.ts | 26 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/app/api/hello/route.ts create mode 100644 src/tests/api/hello.test.ts diff --git a/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json index d1c6c39..2680641 100644 --- a/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +++ b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json @@ -1 +1 @@ -{"version":"4.1.5","results":[[":status-badge.test.ts",{"duration":5.837028000000004,"failed":false}]]} \ No newline at end of file +{"version":"3.2.4","results":[[":src/tests/api/hello.test.ts",{"duration":0,"failed":true}]]} \ No newline at end of file diff --git a/src/app/api/hello/route.ts b/src/app/api/hello/route.ts new file mode 100644 index 0000000..5aa8879 --- /dev/null +++ b/src/app/api/hello/route.ts @@ -0,0 +1,13 @@ +// FILE: src/app/api/hello/route.ts +import { NextRequest, NextResponse } from 'next/server'; + +/** + * GET /api/hello + * Returns a hello world message with the current timestamp + */ +export async function GET(_req: NextRequest) { + return NextResponse.json({ + message: 'Hello World', + timestamp: Date.now(), + }); +} diff --git a/src/tests/api/hello.test.ts b/src/tests/api/hello.test.ts new file mode 100644 index 0000000..a9dc2c4 --- /dev/null +++ b/src/tests/api/hello.test.ts @@ -0,0 +1,26 @@ +// FILE: src/tests/api/hello.test.ts +import { describe, it, expect } from 'vitest'; +import { GET } from '@/app/api/hello/route'; +import { NextRequest } from 'next/server'; + +function createMockNextRequest(method: string = 'GET', url: string = 'http://localhost/api/hello') { + // Partial implementation sufficient for GET handler + return new NextRequest(url, { method }); +} + +describe('GET /api/hello', () => { + it('should return Hello World message and timestamp', async () => { + const req = createMockNextRequest(); + const res = await GET(req); + expect(res.status).toBe(200); + const json = await res.json(); + expect(json).toEqual( + expect.objectContaining({ + message: 'Hello World', + timestamp: expect.any(Number), + }) + ); + // Additional check: timestamp is within the last 5 seconds (to guard against stale/fake responses) + expect(Math.abs(json.timestamp - Date.now())).toBeLessThan(5000); + }); +});