项目文件夹

文件
2026-09-11 21:04:59 +08:00

28 行
1010 B
JavaScript

// function-no-deps 测试数据:裸函数,无逻辑资源引用、无依赖,仅 /health。
const corsHeaders = {
"access-control-allow-methods": "GET,POST,OPTIONS",
"access-control-allow-headers": "content-type",
"access-control-max-age": "86400"
};
const jsonHeaders = { ...corsHeaders, "content-type": "application/json; charset=utf-8" };
exports.handler = async function handler(event) {
const method = (event && (event.method || event.httpMethod)) || "GET";
const path = (event && (event.path || event.rawPath)) || "/api/cloud/health";
if (method === "OPTIONS") {
return { statusCode: 204, headers: corsHeaders, body: "" };
}
if (method === "GET" && path.endsWith("/health")) {
return {
statusCode: 200,
headers: jsonHeaders,
body: JSON.stringify({ ok: true, service: "wehub-tpl-demo-function-no-deps" })
};
}
return {
statusCode: 200,
headers: jsonHeaders,
body: JSON.stringify({ ok: true, routes: ["GET /api/cloud/health"] })
};
};