wehub-cloud-tpl-function-no-deps
acfcaab481
Co-authored-by: Cursor <cursoragent@cursor.com>
28 行
1010 B
JavaScript
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"] })
|
|
};
|
|
};
|