Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

929 B
Raw Blame
import { PluginController, PluginMethod } from '../../nest-rpc/rpc-kit/decorators';
import { num } from '../../nest-rpc/rpc-params';
import { WeatherService } from './weather.service';

/**
 * The weather surface a plugin may reach (#plugins). Tenant-free: a host-cached
 * forecast by coordinates plus an optional date, so no user and no trip.
 *
 * The language is pinned to 'en' exactly as the deps factory pinned it. A plugin
 * has no locale of its own, and the wire contract never carried one.
 */
@PluginController()
export class WeatherRpc {
  constructor(private readonly weather: WeatherService) {}

  @PluginMethod('weather.get', { permission: 'weather:read' })
  get(params: Record<string, unknown>): unknown {
    const lat = num(params.lat, 'lat');
    const lng = num(params.lng, 'lng');
    return this.weather.get(String(lat), String(lng), typeof params.date === 'string' ? params.date : undefined, 'en');
  }
}