|
1 | 1 | /* eslint-disable @typescript-eslint/ban-types */ |
2 | | -import { |
3 | | - ConnectionInitMessage, |
4 | | - PingMessage, |
5 | | - PongMessage, |
6 | | -} from 'graphql-ws' |
| 2 | +import { ConnectionInitMessage, PingMessage, PongMessage } from 'graphql-ws' |
7 | 3 | import { DataMapper } from '@aws/dynamodb-data-mapper' |
8 | | -import { |
9 | | - APIGatewayEventRequestContext, |
10 | | - APIGatewayProxyEvent, |
11 | | -} from 'aws-lambda' |
| 4 | +import { APIGatewayEventRequestContext, APIGatewayProxyEvent } from 'aws-lambda' |
12 | 5 | import { GraphQLResolveInfo, GraphQLSchema } from 'graphql' |
13 | 6 | import { DynamoDB } from 'aws-sdk' |
14 | 7 | import { Subscription } from './model/Subscription' |
15 | 8 | import { Connection } from './model/Connection' |
| 9 | +import { publish } from './pubsub/publish' |
| 10 | +import { complete } from './pubsub/complete' |
| 11 | +import { handleGatewayEvent } from './gateway' |
| 12 | +import { handleStateMachineEvent } from './stepFunctionHandler' |
16 | 13 |
|
17 | 14 | export type ServerArgs = { |
18 | 15 | schema: GraphQLSchema |
@@ -53,6 +50,13 @@ export type ServerClosure = { |
53 | 50 | } |
54 | 51 | } & Omit<ServerArgs, 'tableNames'> |
55 | 52 |
|
| 53 | +export interface ServerInstance { |
| 54 | + gatewayHandler: ReturnType<typeof handleGatewayEvent> |
| 55 | + stateMachineHandler:ReturnType<typeof handleStateMachineEvent> |
| 56 | + publish:ReturnType<typeof publish> |
| 57 | + complete: ReturnType<typeof complete> |
| 58 | +} |
| 59 | + |
56 | 60 | export type TableNames = { |
57 | 61 | connections: string |
58 | 62 | subscriptions: string |
@@ -108,7 +112,6 @@ export type PubSubEvent = { |
108 | 112 |
|
109 | 113 | export type MessageHandler<T> = (arg: { server: ServerClosure, event: APIGatewayWebSocketEvent, message: T }) => Promise<void> |
110 | 114 |
|
111 | | - |
112 | 115 | /* |
113 | 116 | Matches the ApiGatewayManagementApi class from aws-sdk but only provides the methods we use |
114 | 117 | */ |
|
0 commit comments