UNPKG

@ririaru/mcp-gpt5-server

Version:

Enhanced MCP server for GPT-5 with advanced features

95 lines (81 loc) 2.97 kB
// 薄いプロキシの動作確認テスト import fs from 'fs'; console.log('🔗 Testing Thin Vercel Proxy...'); // 薄いプロキシのコードを動的にインポート const proxyCode = fs.readFileSync('api/messages-new.js', 'utf8'); // Vercel環境のシミュレーション function createMockResponse() { const response = { statusCode: 200, headers: {}, body: null, status(code) { this.statusCode = code; return this; }, json(data) { this.body = data; return this; }, setHeader(key, value) { this.headers[key] = value; return this; } }; return response; } // プロキシハンドラーをテスト async function testThinProxy() { try { // 動的インポートでプロキシを読み込み const { default: handler } = await import('./api/messages-new.js'); console.log('✅ Proxy imported successfully'); // Test cases const tests = [ { name: "Basic request", req: { method: "POST", body: { prompt: "Hello thin proxy" } }, expectStatus: 200 }, { name: "Level override", req: { method: "POST", body: { prompt: "High level test", level: "high" } }, expectStatus: 200 }, { name: "Verbosity override", req: { method: "POST", body: { prompt: "Verbose test", verbosity: "verbose" } }, expectStatus: 200 }, { name: "Missing prompt", req: { method: "POST", body: {} }, expectStatus: 400 }, { name: "Wrong method", req: { method: "GET", body: { prompt: "test" } }, expectStatus: 405 } ]; for (const test of tests) { console.log(`\n🧪 Test: ${test.name}`); const res = createMockResponse(); await handler(test.req, res); console.log(` Status: ${res.statusCode} (expected: ${test.expectStatus})`); console.log(` ✅ Status check: ${res.statusCode === test.expectStatus ? 'PASS' : 'FAIL'}`); if (res.body) { console.log(` Body keys: ${Object.keys(res.body).join(', ')}`); if (res.statusCode === 200) { console.log(` ✅ Has content: ${res.body.content ? 'PASS' : 'FAIL'}`); console.log(` ✅ Has cached field: ${res.body.cached !== undefined ? 'PASS' : 'FAIL'}`); console.log(` ✅ Has level field: ${res.body.level ? 'PASS' : 'FAIL'}`); } } } console.log('\n🎉 Thin proxy tests completed successfully!'); return true; } catch (error) { console.error('❌ Thin proxy test failed:', error.message); console.error('Stack:', error.stack); return false; } } testThinProxy().then(success => { if (success) { console.log('\n🚀 Thin proxy ready for deployment!'); } else { console.log('\n❌ Thin proxy tests failed'); } });