sst 2.24.16 → 2.24.17
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/node/api/index.d.ts +4 -0
- package/node/api/index.js +17 -1
- package/node/future/auth/session.js +1 -3
- package/package.json +1 -1
package/node/api/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type ApiHandlerTypes = Extract<HandlerTypes, "api" | "ws">;
|
|
|
10
10
|
export declare const Api: ApiResources;
|
|
11
11
|
export declare const AppSyncApi: AppSyncApiResources;
|
|
12
12
|
export declare const ApiGatewayV1Api: ApiGatewayV1ApiResources;
|
|
13
|
+
export declare class Response {
|
|
14
|
+
readonly result: APIGatewayProxyStructuredResultV2;
|
|
15
|
+
constructor(result: APIGatewayProxyStructuredResultV2);
|
|
16
|
+
}
|
|
13
17
|
/**
|
|
14
18
|
* Create a new api handler that can be used to create an authenticated session.
|
|
15
19
|
*
|
package/node/api/index.js
CHANGED
|
@@ -6,6 +6,12 @@ export const AppSyncApi =
|
|
|
6
6
|
/* @__PURE__ */ createProxy("AppSyncApi");
|
|
7
7
|
export const ApiGatewayV1Api =
|
|
8
8
|
/* @__PURE__ */ createProxy("ApiGatewayV1Api");
|
|
9
|
+
export class Response {
|
|
10
|
+
result;
|
|
11
|
+
constructor(result) {
|
|
12
|
+
this.result = result;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
9
15
|
/**
|
|
10
16
|
* Create a new api handler that can be used to create an authenticated session.
|
|
11
17
|
*
|
|
@@ -17,7 +23,17 @@ export const ApiGatewayV1Api =
|
|
|
17
23
|
*/
|
|
18
24
|
export function ApiHandler(cb) {
|
|
19
25
|
return Handler("api", async (evt, ctx) => {
|
|
20
|
-
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
result = await cb(evt, ctx);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
if (e instanceof Response) {
|
|
32
|
+
result = e.result;
|
|
33
|
+
}
|
|
34
|
+
else
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
21
37
|
const serialized = useResponse().serialize(result || {});
|
|
22
38
|
return serialized;
|
|
23
39
|
});
|