Skip to main content
Glama
river.repo.ts1.61 kB
import Database from 'better-sqlite3'; import { RiverPath, RiverPathSchema } from '../../schema/river.js'; export class RiverRepository { constructor(private db: Database.Database) { } create(river: RiverPath): void { const validRiver = RiverPathSchema.parse(river); const stmt = this.db.prepare(` INSERT INTO rivers (id, world_id, name, path, width, source_elevation, mouth_elevation) VALUES (@id, @worldId, @name, @path, @width, @sourceElevation, @mouthElevation) `); stmt.run({ id: validRiver.id, worldId: validRiver.worldId, name: validRiver.name, path: JSON.stringify(validRiver.points), width: validRiver.width, sourceElevation: validRiver.sourceElevation, mouthElevation: validRiver.mouthElevation, }); } findByWorldId(worldId: string): RiverPath[] { const stmt = this.db.prepare('SELECT * FROM rivers WHERE world_id = ?'); const rows = stmt.all(worldId) as RiverRow[]; return rows.map((row) => RiverPathSchema.parse({ id: row.id, worldId: row.world_id, name: row.name, points: JSON.parse(row.path), width: row.width, sourceElevation: row.source_elevation, mouthElevation: row.mouth_elevation, }) ); } } interface RiverRow { id: string; world_id: string; name: string; path: string; width: number; source_elevation: number; mouth_elevation: number; }

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/Mnehmos/rpg-mcp'

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