/**
 * @fileoverview Health check endpoint for Aurora API.
 * Provides a simple health status endpoint for monitoring and load balancers.
 */

import type { RouteContext, RouteModule } from "./types";

/**
 * Health routes handler.
 * 
 * @route GET /api/health
 * @description Returns server health status with timestamp.
 * @response 200 - `{ status: "ok", timestamp: number }`
 * 
 * @example
 * // Request
 * GET /api/health
 * 
 * // Response
 * { "status": "ok", "timestamp": 1707408000000 }
 */
async function handler(ctx: RouteContext): Promise<Response | null> {
    if (ctx.pathname === "/api/health" && ctx.method === "GET") {
        return Response.json({
            status: "ok",
            timestamp: Date.now()
        });
    }

    return null;
}

export const healthRoutes: RouteModule = {
    name: "health",
    handler
};
