@copilotkit/runtime
Version:
<div align="center"> <a href="https://copilotkit.ai" target="_blank"> <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo"> </a>
38 lines (30 loc) • 1.05 kB
text/typescript
import { createYoga } from "graphql-yoga";
import { CreateCopilotRuntimeServerOptions, getCommonConfig } from "../shared";
import telemetry, { getRuntimeInstanceTelemetryInfo } from "../../telemetry-client";
export function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRuntimeServerOptions) {
const commonConfig = getCommonConfig(options);
telemetry.setGlobalProperties({
runtime: {
framework: "nextjs-app-router",
},
});
if (options.properties?._copilotkit) {
telemetry.setGlobalProperties({
_copilotkit: options.properties._copilotkit,
});
}
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
const logger = commonConfig.logging;
logger.debug("Creating NextJS App Router endpoint");
const yoga = createYoga({
...commonConfig,
graphqlEndpoint: options.endpoint,
fetchAPI: { Response: globalThis.Response },
});
return {
handleRequest: yoga,
GET: yoga as any,
POST: yoga as any,
OPTIONS: yoga as any,
};
}