Files
wws-functions/api/index.js
christiankrag 3fcebac27f Switch to ES module exports for wws runtime
- Replace module.exports with export default
- wws uses ES modules, not CommonJS
- Fixes 'module is not defined' error

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 06:01:10 +01:00

41 lines
933 B
JavaScript

// Health check and API info endpoint
// Path: /api
async function handler(request) {
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
'Content-Type': 'application/json'
}
if (request.method === 'OPTIONS') {
return new Response('', { headers: corsHeaders })
}
const response = {
status: 'ok',
service: 'mylder-wws',
version: '1.0.0',
timestamp: new Date().toISOString(),
endpoints: {
health: '/api',
chat: '/chat',
webhook: '/webhook'
},
runtime: 'wasm-workers-server',
features: [
'cloudflare-compatible',
'zero-vendor-lock-in',
'webassembly-sandbox'
]
}
return new Response(JSON.stringify(response, null, 2), {
headers: corsHeaders
})
}
// ES Module export for wws
export default handler