We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/proffillipesilva/mcpnodefil'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { ProductRepository } from '../repositories/product.repository';
import { Product } from '../entities/product.entity';
import { CreateProductDto, UpdateProductDto } from '../dtos/product.dto';
export class ProductService {
private productRepository: ProductRepository;
constructor() {
this.productRepository = new ProductRepository();
}
async createProduct(createProductDto: CreateProductDto): Promise<Product> {
const product = await this.productRepository.create(createProductDto);
return product;
}
async getAllProducts(): Promise<Product[]> {
return await this.productRepository.findAll();
}
async getProductById(id: string): Promise<Product> {
const product = await this.productRepository.findById(id);
if (!product) {
throw new Error('Product not found');
}
return product;
}
async updateProduct(id: string, updateProductDto: UpdateProductDto): Promise<Product> {
const product = await this.productRepository.findById(id);
if (!product) {
throw new Error('Product not found');
}
const updatedProduct = await this.productRepository.update(id, updateProductDto);
if (!updatedProduct) {
throw new Error('Failed to update product');
}
return updatedProduct;
}
async deleteProduct(id: string): Promise<void> {
const product = await this.productRepository.findById(id);
if (!product) {
throw new Error('Product not found');
}
const deleted = await this.productRepository.delete(id);
if (!deleted) {
throw new Error('Failed to delete product');
}
}
}