Files
wws-functions/api/index.js
christiankrag c8a8ea007d Initial wws serverless functions setup
- Add health check API endpoint (/api)
- Add chat proxy to n8n workflow (/chat)
- Add webhook receiver for external integrations (/webhook)
- Add Dockerfile for container deployment
- Add wws.toml configuration

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

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

47 lines
1.0 KiB
JavaScript

// Health check and API info endpoint
// Path: /api
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
// CORS headers for browser requests
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
}
if (request.method === 'OPTIONS') {
return new Response(null, { 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: {
'Content-Type': 'application/json',
...corsHeaders
}
})
}