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>
This commit is contained in:
46
api/index.js
Normal file
46
api/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user