Spaces:
Configuration error
Configuration error
File size: 1,090 Bytes
a336e20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | // cursor-client.js
class DeepSiteClient {
constructor(mcpServerUrl, apiKey) {
this.serverUrl = mcpServerUrl;
this.apiKey = apiKey;
}
async generateComponent(prompt, options = {}) {
try {
const response = await fetch(`${this.serverUrl}/generate`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.apiKey}`
},
body: JSON.stringify({
prompt,
componentType: options.componentType || 'component',
framework: options.framework || 'react'
})
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || 'Failed to generate component');
}
return await response.json();
} catch (error) {
console.error('Generation error:', error);
throw error;
}
}
async checkStatus() {
const response = await fetch(`${this.serverUrl}/status`);
return await response.json();
}
}
// Export for use in Cursor
export default DeepSiteClient;
|