dataforseo-mcp-server
Version:
CLI and MCP server for DataForSEO API — browse documentation and make authenticated API requests
29 lines • 1 kB
JavaScript
import { isLiveEndpoint } from "../live-endpoint.js";
/**
* Enforces the Live-endpoint rule: only the first task object is sent.
*/
export class LiveEndpointApiRequestMiddleware {
name = "live-endpoint-single-task";
apply(ctx) {
if (ctx.body === undefined || !isLiveEndpoint(ctx.path)) {
return { body: ctx.body, warnings: [] };
}
let parsed;
try {
parsed = JSON.parse(ctx.body);
}
catch {
return { body: ctx.body, warnings: [] };
}
if (!Array.isArray(parsed) || parsed.length <= 1) {
return { body: ctx.body, warnings: [] };
}
return {
body: JSON.stringify([parsed[0]]),
warnings: [
"Warning: Live endpoints allow only 1 task per request. Extra tasks in the request body were ignored; the response is for the first task only.",
],
};
}
}
//# sourceMappingURL=live-endpoint-api-request-middleware.js.map