MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / route

Function route

src/server.js:131–505  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

129}
130
131async function route(req, res) {
132 const { method } = req;
133 let path = req.url.split('?')[0];
134
135 if (method === 'OPTIONS') {
136 res.writeHead(204, {
137 'Access-Control-Allow-Origin': '*',
138 'Access-Control-Allow-Methods': 'GET, POST, DELETE, OPTIONS',
139 'Access-Control-Allow-Headers': 'Content-Type, Authorization, x-api-key, anthropic-version',
140 });
141 return res.end();
142 }
143 if (path === '/health') {
144 const counts = getAccountCount();
145 const body = {
146 status: 'ok',
147 provider: 'WindsurfAPI bydwgx1337',
148 version: VERSION_INFO.version,
149 commit: VERSION_INFO.commit,
150 commitMessage: VERSION_INFO.commitMessage,
151 commitDate: VERSION_INFO.commitDate,
152 branch: VERSION_INFO.branch,
153 buildSource: VERSION_INFO.source,
154 uptime: Math.round(process.uptime()),
155 accounts: counts,
156 };
157 const qs = new URL(req.url, 'http://localhost').searchParams;
158 if (qs.get('verbose') === '1' && validateApiKey(extractToken(req))) {
159 try {
160 const { poolStats } = await import('./conversation-pool.js');
161 const { cacheStats } = await import('./cache.js');
162 const { getLsStatus } = await import('./langserver.js');
163 const { getSpecialAgentStatus } = await import('./special-agent.js');
164 const { getNativeBridgeStats } = await import('./native-bridge-stats.js');
165 const { getNativeBridgeConfigStatus } = await import('./cascade-native-bridge.js');
166 body.conversationPool = poolStats();
167 body.cache = cacheStats();
168 body.lsPool = getLsStatus();
169 body.specialAgent = getSpecialAgentStatus();
170 body.nativeBridge = getNativeBridgeStats();
171 body.nativeBridgeConfig = getNativeBridgeConfigStatus();
172 // v2.0.57 Fix 5 — drought summary so monitoring can page on
173 // "all accounts < 5% weekly" without screen-scraping per-account
174 // credit dumps.
175 body.drought = getDroughtSummary();
176 } catch {}
177 }
178 return json(res, 200, body);
179 }
180
181 // ─── Dashboard ─────────────────────────────────────────
182 if (path === '/favicon.ico') {
183 res.writeHead(204);
184 return res.end();
185 }
186 if (path === '/dashboard' || path === '/dashboard/') {
187 try {
188 // Cookie-based skin selection. `dashboard_skin=sketch` serves the

Callers 1

startServerFunction · 0.85

Calls 15

getAccountCountFunction · 0.90
validateApiKeyFunction · 0.90
getDroughtSummaryFunction · 0.90
handleDashboardApiFunction · 0.90
isAuthenticatedFunction · 0.90
getAccountListFunction · 0.90
removeAccountFunction · 0.90
addAccountByKeyFunction · 0.90
addAccountByTokenFunction · 0.90
addAccountByEmailFunction · 0.90
handleModelsFunction · 0.90
callerKeyFromRequestFunction · 0.90

Tested by

no test coverage detected