UNPKG

@the_pixelport/aws-lambda-graphql

Version:

Apollo server for AWS Lambda with WebSocket subscriptions support over API Gateway v1 + v2

70 lines 2.75 kB
/// <reference types="node" /> import { ApiGatewayManagementApiClient } from '@aws-sdk/client-apigatewaymanagementapi'; import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; import { IConnection, IConnectEvent, IConnectionManager, ISubscriptionManager, IConnectionData, HydrateConnectionOptions } from './types'; interface DynamoDBConnection extends IConnection { /** * TTL in UNIX seconds */ ttl?: number; } interface DynamoDBConnectionManagerOptions { /** * Use this to override ApiGatewayManagementApiClient (for example in usage with serverless-offline) * * If not provided it will be created with endpoint from connections */ apiGatewayManager?: ApiGatewayManagementApiClient; /** * Connections table name (default is Connections) */ connectionsTable?: string; /** * Use this to override default document client (for example if you want to use local dynamodb) * * Provide either a DynamoDBDocumentClient or DynamoDBClient (which will be wrapped) */ dynamoDbClient?: DynamoDBDocumentClient | DynamoDBClient; subscriptions: ISubscriptionManager; /** * Optional TTL for connections (stored in ttl field) in seconds * * Default value is 2 hours * * Set to false to turn off TTL */ ttl?: number | false; /** * Enable console.log */ debug?: boolean; } /** * DynamoDBConnectionManager * * Stores connections in DynamoDB table (default table name is Connections, you can override that) */ export declare class DynamoDBConnectionManager implements IConnectionManager { private apiGatewayManager; private connectionsTable; private db; private subscriptions; private ttl; private debug; constructor({ apiGatewayManager, connectionsTable, dynamoDbClient, subscriptions, ttl, debug, }: DynamoDBConnectionManagerOptions); hydrateConnection: (connectionId: string, options?: HydrateConnectionOptions) => Promise<DynamoDBConnection>; setConnectionData: (data: IConnectionData, { id }: DynamoDBConnection) => Promise<void>; registerConnection: ({ connectionId, endpoint, }: IConnectEvent) => Promise<DynamoDBConnection>; sendToConnection: (connection: DynamoDBConnection, payload: string | Buffer) => Promise<void>; unregisterConnection: ({ id }: DynamoDBConnection) => Promise<void>; closeConnection: ({ id, data }: DynamoDBConnection) => Promise<void>; /** * Creates api gateway manager * * If custom api gateway manager is provided, uses it instead */ private createApiGatewayManager; } export {}; //# sourceMappingURL=DynamoDBConnectionManager.d.ts.map