Skip to main content
Glama
create-weather.handler.ts866 B
import { CommandHandler, ICommandHandler } from "@nestjs/cqrs" import { CreateWeatherCommand } from "./create-weather.command" import { CreateWeatherResponse } from "./create-weather.response" import { IWeatherRepository } from "src/domain/weather/weather.repository" import { Weather } from "src/domain/weather/weather" @CommandHandler(CreateWeatherCommand) export class CreateWeatherHandler implements ICommandHandler<CreateWeatherCommand, CreateWeatherResponse> { constructor( private _weatherRepository: IWeatherRepository ) { } async execute(command: CreateWeatherCommand): Promise<CreateWeatherResponse> { const weather = new Weather(new Date(command.date), command.temperature) await this._weatherRepository.Insert(weather) return CreateWeatherResponse.from(weather.Date.toISOString(), weather.Temperature) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RenzoReccio/nestjs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server