sst-http 2.0.0-beta.6 → 2.0.0-beta.7
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/dist/infra.cjs +12 -11
- package/dist/infra.js +12 -11
- package/package.json +1 -1
package/dist/infra.cjs
CHANGED
|
@@ -48,13 +48,14 @@ function ensureRecord(value, message) {
|
|
|
48
48
|
return value;
|
|
49
49
|
}
|
|
50
50
|
function ensureSstAws(source) {
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
51
|
+
const awsData = typeof sst !== "undefined" ? sst.aws : source?.sst?.aws ?? globalThis.sst?.aws;
|
|
52
|
+
if (!awsData) {
|
|
53
53
|
throw new Error(
|
|
54
54
|
"SST aws namespace is not available. Ensure this code runs within an SST config."
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
awsData.iam = aws.iam;
|
|
58
|
+
return awsData;
|
|
58
59
|
}
|
|
59
60
|
function resolveHandlerInput(handler) {
|
|
60
61
|
if (handler === void 0) {
|
|
@@ -81,7 +82,7 @@ function wireEventsFromManifest(events, opts) {
|
|
|
81
82
|
if (!events || events.length === 0) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
|
-
const
|
|
85
|
+
const aws2 = ensureSstAws(opts.source);
|
|
85
86
|
const subscriber = resolveHandlerInput(opts.handler);
|
|
86
87
|
const seen = /* @__PURE__ */ new Set();
|
|
87
88
|
for (const event of events) {
|
|
@@ -90,7 +91,7 @@ function wireEventsFromManifest(events, opts) {
|
|
|
90
91
|
continue;
|
|
91
92
|
}
|
|
92
93
|
seen.add(key);
|
|
93
|
-
const bus =
|
|
94
|
+
const bus = aws2.Bus.get("default", "default");
|
|
94
95
|
const subscriberName = buildSubscriberName(event.event);
|
|
95
96
|
subscribeToBus(bus, subscriberName, subscriber, event.event);
|
|
96
97
|
}
|
|
@@ -136,8 +137,8 @@ function wireRoutesFromManifest(manifest, opts) {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
function httpApiAdapter(args) {
|
|
139
|
-
const
|
|
140
|
-
const api = args?.api ?? new
|
|
140
|
+
const aws2 = args?.api ? void 0 : ensureSstAws(args);
|
|
141
|
+
const api = args?.api ?? new aws2.ApiGatewayV2(args?.apiName ?? "HttpApi", args?.apiArgs);
|
|
141
142
|
const ensureJwtAuthorizer = createHttpAuthorizerManager(api);
|
|
142
143
|
const registerRoute = createRouteRegistrar(api, "ApiGatewayV2");
|
|
143
144
|
return {
|
|
@@ -147,8 +148,8 @@ function httpApiAdapter(args) {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
function restApiAdapter(args) {
|
|
150
|
-
const
|
|
151
|
-
const api = args?.api ?? new
|
|
151
|
+
const aws2 = args?.api ? void 0 : ensureSstAws(args);
|
|
152
|
+
const api = args?.api ?? new aws2.ApiGateway(args?.apiName ?? "RestApi", args?.apiArgs);
|
|
152
153
|
const ensureJwtAuthorizer = createRestAuthorizerManager(api);
|
|
153
154
|
const registerRoute = createRouteRegistrar(api, "ApiGateway");
|
|
154
155
|
return {
|
|
@@ -330,8 +331,8 @@ function loadRoutesManifest(filePath) {
|
|
|
330
331
|
return manifest;
|
|
331
332
|
}
|
|
332
333
|
function setHandlerBus(handler) {
|
|
333
|
-
const
|
|
334
|
-
new
|
|
334
|
+
const aws2 = ensureSstAws();
|
|
335
|
+
new aws2.iam.RolePolicy("PublisherHandlerPolicy", {
|
|
335
336
|
role: handler.nodes.role.name,
|
|
336
337
|
policy: {
|
|
337
338
|
Version: "2012-10-17",
|
package/dist/infra.js
CHANGED
|
@@ -24,13 +24,14 @@ function ensureRecord(value, message) {
|
|
|
24
24
|
return value;
|
|
25
25
|
}
|
|
26
26
|
function ensureSstAws(source) {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const awsData = typeof sst !== "undefined" ? sst.aws : source?.sst?.aws ?? globalThis.sst?.aws;
|
|
28
|
+
if (!awsData) {
|
|
29
29
|
throw new Error(
|
|
30
30
|
"SST aws namespace is not available. Ensure this code runs within an SST config."
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
awsData.iam = aws.iam;
|
|
34
|
+
return awsData;
|
|
34
35
|
}
|
|
35
36
|
function resolveHandlerInput(handler) {
|
|
36
37
|
if (handler === void 0) {
|
|
@@ -57,7 +58,7 @@ function wireEventsFromManifest(events, opts) {
|
|
|
57
58
|
if (!events || events.length === 0) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
const
|
|
61
|
+
const aws2 = ensureSstAws(opts.source);
|
|
61
62
|
const subscriber = resolveHandlerInput(opts.handler);
|
|
62
63
|
const seen = /* @__PURE__ */ new Set();
|
|
63
64
|
for (const event of events) {
|
|
@@ -66,7 +67,7 @@ function wireEventsFromManifest(events, opts) {
|
|
|
66
67
|
continue;
|
|
67
68
|
}
|
|
68
69
|
seen.add(key);
|
|
69
|
-
const bus =
|
|
70
|
+
const bus = aws2.Bus.get("default", "default");
|
|
70
71
|
const subscriberName = buildSubscriberName(event.event);
|
|
71
72
|
subscribeToBus(bus, subscriberName, subscriber, event.event);
|
|
72
73
|
}
|
|
@@ -106,8 +107,8 @@ function wireRoutesFromManifest(manifest, opts) {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
function httpApiAdapter(args) {
|
|
109
|
-
const
|
|
110
|
-
const api = args?.api ?? new
|
|
110
|
+
const aws2 = args?.api ? void 0 : ensureSstAws(args);
|
|
111
|
+
const api = args?.api ?? new aws2.ApiGatewayV2(args?.apiName ?? "HttpApi", args?.apiArgs);
|
|
111
112
|
const ensureJwtAuthorizer = createHttpAuthorizerManager(api);
|
|
112
113
|
const registerRoute = createRouteRegistrar(api, "ApiGatewayV2");
|
|
113
114
|
return {
|
|
@@ -117,8 +118,8 @@ function httpApiAdapter(args) {
|
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
function restApiAdapter(args) {
|
|
120
|
-
const
|
|
121
|
-
const api = args?.api ?? new
|
|
121
|
+
const aws2 = args?.api ? void 0 : ensureSstAws(args);
|
|
122
|
+
const api = args?.api ?? new aws2.ApiGateway(args?.apiName ?? "RestApi", args?.apiArgs);
|
|
122
123
|
const ensureJwtAuthorizer = createRestAuthorizerManager(api);
|
|
123
124
|
const registerRoute = createRouteRegistrar(api, "ApiGateway");
|
|
124
125
|
return {
|
|
@@ -300,8 +301,8 @@ function loadRoutesManifest(filePath) {
|
|
|
300
301
|
return manifest;
|
|
301
302
|
}
|
|
302
303
|
function setHandlerBus(handler) {
|
|
303
|
-
const
|
|
304
|
-
new
|
|
304
|
+
const aws2 = ensureSstAws();
|
|
305
|
+
new aws2.iam.RolePolicy("PublisherHandlerPolicy", {
|
|
305
306
|
role: handler.nodes.role.name,
|
|
306
307
|
policy: {
|
|
307
308
|
Version: "2012-10-17",
|