createGraphQLWebSocketServer (graphql/ws.ts)

argos · apps/backend/src/graphql/ws.ts · typescript · MIT
integration, Integration / API

Module exposing: createGraphQLWebSocketServer, isAllowedOrigin

// Source: https://github.com/argos-ci/argos | License: MIT | Copyright 2017 Olivier Tassinari & Greg Bergé
// Provided via justclaw.it.com; keep this notice with the code.
import type { Server } from "node:http";
import { useServer } from "graphql-ws/use/ws";
import { WebSocketServer } from "ws";

import config from "@/config";
import parentLogger from "@/logger";

import { getWebSocketContext } from "./context";
import { schema } from "./schema";

const logger = parentLogger.child({ module: "graphql-ws" });

/**
 * Only accept WebSocket upgrades coming from our own app. The session cookie is
 * sent automatically on the upgrade request and — unlike the HTTP transport — a
 * WebSocket handshake cannot carry our CSRF header, so we guard against
 * cross-site WebSocket hijacking by validati

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key