- Update api/index.js to use handler export format
- Update chat/index.js to use handler export format
- Update webhook/index.js to use handler export format
- Remove addEventListener('fetch') pattern incompatible with wws
- Remove URL API usage (not available in wws JS runtime)
- Remove spread operator for better compatibility
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
42 lines
968 B
JavaScript
42 lines
968 B
JavaScript
// Health check and API info endpoint
|
|
// Path: /api
|
|
|
|
async function handler(request) {
|
|
// 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',
|
|
'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
|
|
})
|
|
}
|
|
|
|
// Export for wws
|
|
module.exports = { handler }
|