Files
vue-ts-example-2025/server/index.ts
严浩 e50d699a2a
Some checks failed
/ playwright (push) Successful in 1m33s
/ build-and-test (push) Failing after 2m7s
CI/CD Pipeline / build-and-deploy (push) Successful in 2m16s
CI/CD Pipeline / playwright (push) Successful in 3m26s
chore: initial commit
2025-10-15 16:27:39 +08:00

19 lines
565 B
TypeScript

export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.hostname === 'localhost' || url.hostname === '127.0.0.1')
await new Promise((r) => setTimeout(r, 250));
if (url.pathname.startsWith('/api/')) {
await env.KV.put('last-api-call', `${Date.now()} ${request.method} ${url.pathname}`);
return Response.json({
timestamp: Date.now(),
lastApiCall: await env.KV.get('last-api-call'),
});
}
return new Response(null, { status: 404 });
},
} satisfies ExportedHandler<Env>;