Skip to content
This repository was archived by the owner on May 17, 2025. It is now read-only.

Commit e45c1bd

Browse files
committed
feat: different type exports
1 parent 6c0b2fd commit e45c1bd

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

lib/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { ServerArgs, ServerClosure } from './types'
1+
import { ServerArgs, ServerClosure, ServerInstance } from './types'
22
import { publish } from './pubsub/publish'
33
import { complete } from './pubsub/complete'
44
import { handleGatewayEvent } from './gateway'
55
import { handleStateMachineEvent } from './stepFunctionHandler'
66
import { makeServerClosure } from './makeServerClosure'
77

8-
export const createInstance = (opts: ServerArgs) => {
8+
export const createInstance = (opts: ServerArgs): ServerInstance => {
99
const closure: ServerClosure = makeServerClosure(opts)
1010

1111
return {
@@ -17,7 +17,6 @@ export const createInstance = (opts: ServerArgs) => {
1717
}
1818

1919
export * from './pubsub/subscribe'
20-
2120
export * from './types'
2221
export { Subscription } from './model/Subscription'
2322
export { Connection } from './model/Connection'

lib/types.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
/* 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'
73
import { DataMapper } from '@aws/dynamodb-data-mapper'
8-
import {
9-
APIGatewayEventRequestContext,
10-
APIGatewayProxyEvent,
11-
} from 'aws-lambda'
4+
import { APIGatewayEventRequestContext, APIGatewayProxyEvent } from 'aws-lambda'
125
import { GraphQLResolveInfo, GraphQLSchema } from 'graphql'
136
import { DynamoDB } from 'aws-sdk'
147
import { Subscription } from './model/Subscription'
158
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'
1613

1714
export type ServerArgs = {
1815
schema: GraphQLSchema
@@ -53,6 +50,13 @@ export type ServerClosure = {
5350
}
5451
} & Omit<ServerArgs, 'tableNames'>
5552

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+
5660
export type TableNames = {
5761
connections: string
5862
subscriptions: string
@@ -108,7 +112,6 @@ export type PubSubEvent = {
108112

109113
export type MessageHandler<T> = (arg: { server: ServerClosure, event: APIGatewayWebSocketEvent, message: T }) => Promise<void>
110114

111-
112115
/*
113116
Matches the ApiGatewayManagementApi class from aws-sdk but only provides the methods we use
114117
*/

0 commit comments

Comments
 (0)