Skip to main content
Glama
iotSecurity.ts744 B
// iotSecurity.ts import { IotControlParams } from '@/types'; // 简单 token 鉴权(实际可接入更复杂的鉴权体系) export function checkAuth(token?: string): boolean { // 这里可接入实际的 token 校验逻辑 return token === process.env.IOT_CONTROL_TOKEN; } // 操作频率限制(简单实现,实际可用 redis 等持久化方案) const actionTimestamps: Record<string, number> = {}; const MIN_INTERVAL = 3000; // 3 秒 export function checkRateLimit(deviceId: string, action: string): boolean { const key = `${deviceId}:${action}`; const now = Date.now(); if (actionTimestamps[key] && now - actionTimestamps[key] < MIN_INTERVAL) { return false; } actionTimestamps[key] = now; return true; }

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/chendaleiQ/mcp-iot'

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