@mstuercke/api-utils 5.1.0 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mstuercke/api-utils",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -10,7 +10,7 @@ import {TrpcSubscriptionResponse} from './TrpcSubscriptionResponse';
10
10
 
11
11
  export const awsLambdaTrpcSubscriptionRequestHandler = <Router extends AnyTRPCRouter>(opts: {
12
12
  router: Router
13
- createContext?: (event: APIGatewayProxyEvent) => Promise<inferRouterContext<Router>>
13
+ createContext?: (event: APIGatewayProxyEvent) => inferRouterContext<Router> | Promise<inferRouterContext<Router>>
14
14
  }) => {
15
15
  const {router, createContext} = opts;
16
16
 
@@ -18,7 +18,7 @@ export const awsLambdaTrpcSubscriptionRequestHandler = <Router extends AnyTRPCRo
18
18
  const connection = getConnection(event);
19
19
 
20
20
  if (!event.body || event.body === '[]')
21
- return {statusCode: 200, body: ''};
21
+ return {statusCode: 200, body: '{}'};
22
22
 
23
23
  const request = (JSON.parse(event.body) as TrpcSubscriptionRequest);
24
24
 
@@ -52,7 +52,7 @@ export const awsLambdaTrpcSubscriptionRequestHandler = <Router extends AnyTRPCRo
52
52
  procedures: router._def.procedures,
53
53
  path: request.params.path,
54
54
  type: 'subscription',
55
- ctx: createContext?.(event) || {},
55
+ ctx: await createContext?.(event) || {},
56
56
  getRawInput: async () => request.params.input,
57
57
  })) as Observable<unknown, unknown>;
58
58
 
@@ -100,7 +100,7 @@ export const awsLambdaTrpcSubscriptionRequestHandler = <Router extends AnyTRPCRo
100
100
 
101
101
  return {
102
102
  statusCode: 200,
103
- body: '',
103
+ body: '{}',
104
104
  };
105
105
  };
106
106
  };