mcp-image-server
Version:
Servidor MCP para geração de imagens e ícones, integrado ao Vibecoding.
45 lines (44 loc) • 1.42 kB
JavaScript
export class StorageService {
storagePath;
constructor(storagePath) {
this.storagePath = storagePath;
}
async saveImage(imageBuffer, imageName) {
const fs = require('fs').promises;
const path = require('path');
const filePath = path.join(this.storagePath, imageName);
await fs.writeFile(filePath, imageBuffer);
return filePath;
}
async saveIcon(iconBuffer, iconName) {
const fs = require('fs').promises;
const path = require('path');
const filePath = path.join(this.storagePath, iconName);
await fs.writeFile(filePath, iconBuffer);
return filePath;
}
async getImage(imageName) {
const fs = require('fs').promises;
const path = require('path');
const filePath = path.join(this.storagePath, imageName);
try {
return await fs.readFile(filePath);
}
catch (error) {
console.error(`Error reading image: ${error}`);
return null;
}
}
async getIcon(iconName) {
const fs = require('fs').promises;
const path = require('path');
const filePath = path.join(this.storagePath, iconName);
try {
return await fs.readFile(filePath);
}
catch (error) {
console.error(`Error reading icon: ${error}`);
return null;
}
}
}