sst 2.42.0 → 2.43.1
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/cli/commands/secrets/list.js +1 -1
- package/constructs/AstroSite.d.ts +6 -32
- package/constructs/NextjsSite.d.ts +37 -127
- package/constructs/NextjsSite.js +188 -278
- package/constructs/RemixSite.d.ts +3 -0
- package/constructs/SolidStartSite.d.ts +3 -0
- package/constructs/SsrFunction.d.ts +4 -2
- package/constructs/SsrFunction.js +6 -1
- package/constructs/SsrSite.d.ts +16 -8
- package/constructs/SsrSite.js +30 -26
- package/constructs/SvelteKitSite.d.ts +3 -0
- package/node/future/auth/adapter/apple.d.ts +7 -3
- package/node/future/auth/adapter/apple.js +5 -9
- package/node/future/auth/adapter/google.d.ts +2 -17
- package/node/future/auth/adapter/google.js +19 -22
- package/package.json +2 -2
- package/support/dotnet8-bootstrap/Program.cs +17 -0
- package/support/dotnet8-bootstrap/dotnet-bootstrap.csproj +12 -0
- package/support/dotnet8-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet8-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap.deps.json +59 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap.dll +0 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap.pdb +0 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +13 -0
- package/support/ssr-warmer/index.mjs +52 -49
|
@@ -29,6 +29,7 @@ export class SsrFunction extends Construct {
|
|
|
29
29
|
/** @internal */
|
|
30
30
|
_doNotAllowOthersToBind = true;
|
|
31
31
|
function;
|
|
32
|
+
functionUrl;
|
|
32
33
|
assetReplacer;
|
|
33
34
|
assetReplacerPolicy;
|
|
34
35
|
missingSourcemap;
|
|
@@ -80,11 +81,15 @@ export class SsrFunction extends Construct {
|
|
|
80
81
|
get functionName() {
|
|
81
82
|
return this.function.functionName;
|
|
82
83
|
}
|
|
84
|
+
get url() {
|
|
85
|
+
return this.functionUrl?.url;
|
|
86
|
+
}
|
|
83
87
|
addEnvironment(key, value) {
|
|
84
88
|
return this.function.addEnvironment(key, value);
|
|
85
89
|
}
|
|
86
90
|
addFunctionUrl(props) {
|
|
87
|
-
|
|
91
|
+
this.functionUrl = this.function.addFunctionUrl(props);
|
|
92
|
+
return this.functionUrl;
|
|
88
93
|
}
|
|
89
94
|
grantInvoke(grantee) {
|
|
90
95
|
return this.function.grantInvoke(grantee);
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
|
|
3
3
|
import { Function as CdkFunction, FunctionProps as CdkFunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
|
-
import { ICachePolicy, IResponseHeadersPolicy, ViewerProtocolPolicy, AllowedMethods,
|
|
4
|
+
import { ICachePolicy, IResponseHeadersPolicy, ViewerProtocolPolicy, AllowedMethods, ErrorResponse } from "aws-cdk-lib/aws-cloudfront";
|
|
5
5
|
import { S3OriginProps } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
6
6
|
import { DistributionDomainProps } from "./Distribution.js";
|
|
7
7
|
import { SSTConstruct } from "./Construct.js";
|
|
@@ -13,26 +13,27 @@ import { Size } from "./util/size.js";
|
|
|
13
13
|
import { Duration } from "./util/duration.js";
|
|
14
14
|
import { Permissions } from "./util/permission.js";
|
|
15
15
|
import { BindingResource, BindingProps } from "./util/binding.js";
|
|
16
|
-
type CloudFrontFunctionConfig = {
|
|
16
|
+
export type CloudFrontFunctionConfig = {
|
|
17
17
|
constructId: string;
|
|
18
18
|
injections: string[];
|
|
19
19
|
};
|
|
20
|
-
type EdgeFunctionConfig = {
|
|
20
|
+
export type EdgeFunctionConfig = {
|
|
21
21
|
constructId: string;
|
|
22
22
|
function: EdgeFunctionProps;
|
|
23
23
|
};
|
|
24
|
-
type FunctionOriginConfig = {
|
|
24
|
+
export type FunctionOriginConfig = {
|
|
25
25
|
type: "function";
|
|
26
26
|
constructId: string;
|
|
27
27
|
function: SsrFunctionProps;
|
|
28
28
|
injections?: string[];
|
|
29
29
|
streaming?: boolean;
|
|
30
|
+
warm?: number;
|
|
30
31
|
};
|
|
31
|
-
type ImageOptimizationFunctionOriginConfig = {
|
|
32
|
+
export type ImageOptimizationFunctionOriginConfig = {
|
|
32
33
|
type: "image-optimization-function";
|
|
33
34
|
function: CdkFunctionProps;
|
|
34
35
|
};
|
|
35
|
-
type S3OriginConfig = {
|
|
36
|
+
export type S3OriginConfig = {
|
|
36
37
|
type: "s3";
|
|
37
38
|
originPath?: string;
|
|
38
39
|
copy: {
|
|
@@ -42,7 +43,7 @@ type S3OriginConfig = {
|
|
|
42
43
|
versionedSubDir?: string;
|
|
43
44
|
}[];
|
|
44
45
|
};
|
|
45
|
-
type OriginGroupConfig = {
|
|
46
|
+
export type OriginGroupConfig = {
|
|
46
47
|
type: "group";
|
|
47
48
|
primaryOriginName: string;
|
|
48
49
|
fallbackOriginName: string;
|
|
@@ -424,11 +425,12 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
424
425
|
protected doNotDeploy: boolean;
|
|
425
426
|
protected bucket: Bucket;
|
|
426
427
|
protected serverFunction?: EdgeFunction | SsrFunction;
|
|
428
|
+
protected serverFunctions: SsrFunction[];
|
|
429
|
+
protected edgeFunctions: Record<string, EdgeFunction>;
|
|
427
430
|
private serverFunctionForDev?;
|
|
428
431
|
private edge?;
|
|
429
432
|
private distribution;
|
|
430
433
|
constructor(scope: Construct, id: string, rawProps?: SsrSiteProps);
|
|
431
|
-
protected static buildDefaultServerCachePolicyProps(allowedHeaders: string[]): CachePolicyProps;
|
|
432
434
|
/**
|
|
433
435
|
* The CloudFront URL of the website.
|
|
434
436
|
*/
|
|
@@ -495,6 +497,9 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
495
497
|
allowedHeaders?: string[];
|
|
496
498
|
};
|
|
497
499
|
buildId?: string;
|
|
500
|
+
warmer?: {
|
|
501
|
+
function: string;
|
|
502
|
+
};
|
|
498
503
|
}): {
|
|
499
504
|
cloudFrontFunctions?: CloudFrontFunctions | undefined;
|
|
500
505
|
edgeFunctions?: EdgeFunctions | undefined;
|
|
@@ -513,6 +518,9 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
|
|
|
513
518
|
allowedHeaders?: string[] | undefined;
|
|
514
519
|
} | undefined;
|
|
515
520
|
buildId?: string | undefined;
|
|
521
|
+
warmer?: {
|
|
522
|
+
function: string;
|
|
523
|
+
} | undefined;
|
|
516
524
|
};
|
|
517
525
|
}
|
|
518
526
|
export declare const useSites: () => {
|
package/constructs/SsrSite.js
CHANGED
|
@@ -49,6 +49,8 @@ export class SsrSite extends Construct {
|
|
|
49
49
|
doNotDeploy;
|
|
50
50
|
bucket;
|
|
51
51
|
serverFunction;
|
|
52
|
+
serverFunctions = [];
|
|
53
|
+
edgeFunctions = {};
|
|
52
54
|
serverFunctionForDev;
|
|
53
55
|
edge;
|
|
54
56
|
distribution;
|
|
@@ -87,6 +89,7 @@ export class SsrSite extends Construct {
|
|
|
87
89
|
}
|
|
88
90
|
let s3DeployCRs = [];
|
|
89
91
|
let ssrFunctions = [];
|
|
92
|
+
let warmConfig = [];
|
|
90
93
|
let singletonUrlSigner;
|
|
91
94
|
let singletonCachePolicy;
|
|
92
95
|
let singletonOriginRequestPolicy;
|
|
@@ -107,6 +110,8 @@ export class SsrSite extends Construct {
|
|
|
107
110
|
createWarmer();
|
|
108
111
|
this.bucket = bucket;
|
|
109
112
|
this.distribution = distribution;
|
|
113
|
+
this.serverFunctions = [...ssrFunctions];
|
|
114
|
+
this.edgeFunctions = { ...edgeFunctions };
|
|
110
115
|
this.serverFunction = ssrFunctions[0] ?? Object.values(edgeFunctions)[0];
|
|
111
116
|
this.edge = plan.edge;
|
|
112
117
|
app.registerTypes(this);
|
|
@@ -213,27 +218,26 @@ export class SsrSite extends Construct {
|
|
|
213
218
|
// note: Currently all sites have a single server function. When we add
|
|
214
219
|
// support for multiple server functions (ie. route splitting), we
|
|
215
220
|
// need to handle warming multiple functions.
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
if (warm && plan.edge) {
|
|
219
|
-
throw new VisibleError(`In the "${id}" Site, warming is currently supported only for the regional mode.`);
|
|
221
|
+
if (warm && ssrFunctions[0] instanceof SsrFunction) {
|
|
222
|
+
warmConfig.push({ concurrency: warm, function: ssrFunctions[0] });
|
|
220
223
|
}
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
const warmParams = warmConfig.map((config) => ({
|
|
225
|
+
concurrency: config.concurrency,
|
|
226
|
+
function: config.function.functionName,
|
|
227
|
+
}));
|
|
223
228
|
// Create warmer function
|
|
224
229
|
const warmer = new CdkFunction(self, "WarmerFunction", {
|
|
225
230
|
description: "SSR warmer",
|
|
226
|
-
code: Code.fromAsset(path.join(__dirname, "../support/ssr-warmer")),
|
|
231
|
+
code: Code.fromAsset(plan.warmer?.function ?? path.join(__dirname, "../support/ssr-warmer")),
|
|
227
232
|
runtime: Runtime.NODEJS_18_X,
|
|
228
233
|
handler: "index.handler",
|
|
229
234
|
timeout: CdkDuration.minutes(15),
|
|
230
235
|
memorySize: 128,
|
|
231
236
|
environment: {
|
|
232
|
-
|
|
233
|
-
CONCURRENCY: warm.toString(),
|
|
237
|
+
WARM_PARAMS: JSON.stringify(warmParams),
|
|
234
238
|
},
|
|
235
239
|
});
|
|
236
|
-
|
|
240
|
+
warmConfig.forEach((config) => config.function.grantInvoke(warmer));
|
|
237
241
|
// Create cron job
|
|
238
242
|
new Rule(self, "WarmerRule", {
|
|
239
243
|
schedule: Schedule.rate(CdkDuration.minutes(5)),
|
|
@@ -461,6 +465,9 @@ function handler(event) {
|
|
|
461
465
|
prefetchSecrets: regional?.prefetchSecrets,
|
|
462
466
|
});
|
|
463
467
|
ssrFunctions.push(fn);
|
|
468
|
+
if (props.warm) {
|
|
469
|
+
warmConfig.push({ concurrency: props.warm, function: fn });
|
|
470
|
+
}
|
|
464
471
|
bucket.grantReadWrite(fn?.role);
|
|
465
472
|
const fnUrl = fn.addFunctionUrl({
|
|
466
473
|
authType: regional?.enableServerUrlIamAuth
|
|
@@ -638,7 +645,19 @@ function handler(event) {
|
|
|
638
645
|
const allowedHeaders = plan.serverCachePolicy?.allowedHeaders ?? [];
|
|
639
646
|
singletonCachePolicy =
|
|
640
647
|
singletonCachePolicy ??
|
|
641
|
-
new CachePolicy(self, "ServerCache",
|
|
648
|
+
new CachePolicy(self, "ServerCache", {
|
|
649
|
+
queryStringBehavior: CacheQueryStringBehavior.all(),
|
|
650
|
+
headerBehavior: allowedHeaders.length > 0
|
|
651
|
+
? CacheHeaderBehavior.allowList(...allowedHeaders)
|
|
652
|
+
: CacheHeaderBehavior.none(),
|
|
653
|
+
cookieBehavior: CacheCookieBehavior.none(),
|
|
654
|
+
defaultTtl: CdkDuration.days(0),
|
|
655
|
+
maxTtl: CdkDuration.days(365),
|
|
656
|
+
minTtl: CdkDuration.days(0),
|
|
657
|
+
enableAcceptEncodingBrotli: true,
|
|
658
|
+
enableAcceptEncodingGzip: true,
|
|
659
|
+
comment: "SST server response cache policy",
|
|
660
|
+
});
|
|
642
661
|
return singletonCachePolicy;
|
|
643
662
|
}
|
|
644
663
|
function useServerBehaviorOriginRequestPolicy() {
|
|
@@ -797,21 +816,6 @@ function handler(event) {
|
|
|
797
816
|
});
|
|
798
817
|
}
|
|
799
818
|
}
|
|
800
|
-
static buildDefaultServerCachePolicyProps(allowedHeaders) {
|
|
801
|
-
return {
|
|
802
|
-
queryStringBehavior: CacheQueryStringBehavior.all(),
|
|
803
|
-
headerBehavior: allowedHeaders.length > 0
|
|
804
|
-
? CacheHeaderBehavior.allowList(...allowedHeaders)
|
|
805
|
-
: CacheHeaderBehavior.none(),
|
|
806
|
-
cookieBehavior: CacheCookieBehavior.none(),
|
|
807
|
-
defaultTtl: CdkDuration.days(0),
|
|
808
|
-
maxTtl: CdkDuration.days(365),
|
|
809
|
-
minTtl: CdkDuration.days(0),
|
|
810
|
-
enableAcceptEncodingBrotli: true,
|
|
811
|
-
enableAcceptEncodingGzip: true,
|
|
812
|
-
comment: "SST server response cache policy",
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
819
|
/**
|
|
816
820
|
* The CloudFront URL of the website.
|
|
817
821
|
*/
|
|
@@ -103,6 +103,9 @@ export declare class SvelteKitSite extends SsrSite {
|
|
|
103
103
|
allowedHeaders?: string[] | undefined;
|
|
104
104
|
} | undefined;
|
|
105
105
|
buildId?: string | undefined;
|
|
106
|
+
warmer?: {
|
|
107
|
+
function: string;
|
|
108
|
+
} | undefined;
|
|
106
109
|
};
|
|
107
110
|
getConstructMetadata(): {
|
|
108
111
|
data: {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { BaseClient } from "openid-client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { BaseClient, Issuer } from "openid-client";
|
|
2
|
+
import { OauthBasicConfig } from "./oauth.js";
|
|
3
|
+
type AppleConfig = OauthBasicConfig & {
|
|
4
|
+
issuer?: Issuer;
|
|
5
|
+
};
|
|
6
|
+
export declare const AppleAdapter: (config: AppleConfig) => () => Promise<{
|
|
4
7
|
type: "success";
|
|
5
8
|
properties: {
|
|
6
9
|
tokenset: import("openid-client").TokenSet;
|
|
@@ -15,3 +18,4 @@ export declare const AppleAdapter: (config: OauthConfig) => () => Promise<{
|
|
|
15
18
|
};
|
|
16
19
|
};
|
|
17
20
|
} | undefined>;
|
|
21
|
+
export {};
|
|
@@ -8,19 +8,15 @@ import { useBody, useCookie, useDomainName, usePathParam, useResponse, } from ".
|
|
|
8
8
|
// Also note that Apple's discover uri does not work for the OAuth flow, as the
|
|
9
9
|
// userinfo_endpoint are not included in the response.
|
|
10
10
|
// await Issuer.discover("https://appleid.apple.com/.well-known/openid-configuration/");
|
|
11
|
-
let
|
|
12
|
-
const issuer = new Proxy({}, {
|
|
13
|
-
get: async function (target, prop) {
|
|
14
|
-
if (!realIssuer) {
|
|
15
|
-
realIssuer = await Issuer.discover("https://appleid.apple.com/.well-known/openid-configuration");
|
|
16
|
-
}
|
|
17
|
-
return realIssuer[prop];
|
|
18
|
-
},
|
|
19
|
-
});
|
|
11
|
+
let issuer;
|
|
20
12
|
export const AppleAdapter =
|
|
21
13
|
/* @__PURE__ */
|
|
22
14
|
(config) => {
|
|
23
15
|
return async function () {
|
|
16
|
+
const doesConfigHasIssuer = config.issuer !== undefined;
|
|
17
|
+
if (!doesConfigHasIssuer && !issuer) {
|
|
18
|
+
issuer = await Issuer.discover("https://appleid.apple.com/.well-known/openid-configuration");
|
|
19
|
+
}
|
|
24
20
|
const step = usePathParam("step");
|
|
25
21
|
const callback = "https://" + useDomainName() + "/callback";
|
|
26
22
|
console.log("callback", callback);
|
|
@@ -11,7 +11,7 @@ type GoogleConfig = (OauthBasicConfig & {
|
|
|
11
11
|
mode: "oidc";
|
|
12
12
|
prompt?: GooglePrompt;
|
|
13
13
|
});
|
|
14
|
-
export declare function GoogleAdapter(config: GoogleConfig): (
|
|
14
|
+
export declare function GoogleAdapter(config: GoogleConfig): () => Promise<{
|
|
15
15
|
type: "success";
|
|
16
16
|
properties: {
|
|
17
17
|
tokenset: import("openid-client").TokenSet;
|
|
@@ -25,24 +25,9 @@ export declare function GoogleAdapter(config: GoogleConfig): (() => Promise<{
|
|
|
25
25
|
location: string;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
}>) | (() => Promise<{
|
|
29
|
-
type: "success";
|
|
30
|
-
properties: {
|
|
31
|
-
tokenset: import("openid-client").TokenSet;
|
|
32
|
-
client: BaseClient;
|
|
33
|
-
};
|
|
34
|
-
} | {
|
|
35
|
-
type: "step";
|
|
36
|
-
properties: {
|
|
37
|
-
statusCode: number;
|
|
38
|
-
headers: {
|
|
39
|
-
location: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
error?: undefined;
|
|
43
28
|
} | {
|
|
44
29
|
type: "error";
|
|
45
30
|
error: import("./oauth.js").OauthError;
|
|
46
31
|
properties?: undefined;
|
|
47
|
-
} | undefined
|
|
32
|
+
} | undefined>;
|
|
48
33
|
export {};
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { Issuer } from "openid-client";
|
|
2
2
|
import { OidcAdapter } from "./oidc.js";
|
|
3
3
|
import { OauthAdapter } from "./oauth.js";
|
|
4
|
-
let
|
|
5
|
-
const issuer = new Proxy({}, {
|
|
6
|
-
get: async function (target, prop) {
|
|
7
|
-
if (!realIssuer) {
|
|
8
|
-
realIssuer = await Issuer.discover("https://accounts.google.com");
|
|
9
|
-
}
|
|
10
|
-
return realIssuer[prop];
|
|
11
|
-
},
|
|
12
|
-
});
|
|
4
|
+
let issuer;
|
|
13
5
|
export function GoogleAdapter(config) {
|
|
14
6
|
/* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
return async function () {
|
|
8
|
+
if (!issuer) {
|
|
9
|
+
issuer = await Issuer.discover("https://accounts.google.com");
|
|
10
|
+
}
|
|
11
|
+
if (config.mode === "oauth") {
|
|
12
|
+
return OauthAdapter({
|
|
13
|
+
issuer: issuer,
|
|
14
|
+
...config,
|
|
15
|
+
params: {
|
|
16
|
+
...(config.accessType && { access_type: config.accessType }),
|
|
17
|
+
...config.params,
|
|
18
|
+
},
|
|
19
|
+
})();
|
|
20
|
+
}
|
|
21
|
+
return OidcAdapter({
|
|
17
22
|
issuer: issuer,
|
|
23
|
+
scope: "openid email profile",
|
|
18
24
|
...config,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
...config.params,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return OidcAdapter({
|
|
26
|
-
issuer: issuer,
|
|
27
|
-
scope: "openid email profile",
|
|
28
|
-
...config,
|
|
29
|
-
});
|
|
25
|
+
})();
|
|
26
|
+
};
|
|
30
27
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.43.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/ws": "^8.5.3",
|
|
119
119
|
"@types/yargs": "^17.0.13",
|
|
120
120
|
"archiver": "^5.3.1",
|
|
121
|
-
"astro-sst": "2.
|
|
121
|
+
"astro-sst": "2.43.1",
|
|
122
122
|
"async": "^3.2.4",
|
|
123
123
|
"tsx": "^3.12.1",
|
|
124
124
|
"typescript": "^5.2.2",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
using System.Reflection;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using Amazon.Lambda.RuntimeSupport;
|
|
4
|
+
|
|
5
|
+
namespace dotnet_bootstrap
|
|
6
|
+
{
|
|
7
|
+
class Program
|
|
8
|
+
{
|
|
9
|
+
static async Task Main(string[] args)
|
|
10
|
+
{
|
|
11
|
+
Assembly asm = Assembly.LoadFrom(args[0]);
|
|
12
|
+
var r = new RuntimeSupportInitializer(args[1]);
|
|
13
|
+
await r.RunLambdaBootstrap();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<OutputType>Exe</OutputType>
|
|
5
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
6
|
+
<RootNamespace>dotnet_bootstrap</RootNamespace>
|
|
7
|
+
</PropertyGroup>
|
|
8
|
+
<ItemGroup>
|
|
9
|
+
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0" />
|
|
10
|
+
</ItemGroup>
|
|
11
|
+
|
|
12
|
+
</Project>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeTarget": {
|
|
3
|
+
"name": ".NETCoreApp,Version=v8.0",
|
|
4
|
+
"signature": ""
|
|
5
|
+
},
|
|
6
|
+
"compilationOptions": {},
|
|
7
|
+
"targets": {
|
|
8
|
+
".NETCoreApp,Version=v8.0": {
|
|
9
|
+
"dotnet-bootstrap/1.0.0": {
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"Amazon.Lambda.RuntimeSupport": "1.10.0"
|
|
12
|
+
},
|
|
13
|
+
"runtime": {
|
|
14
|
+
"dotnet-bootstrap.dll": {}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"Amazon.Lambda.Core/2.2.0": {
|
|
18
|
+
"runtime": {
|
|
19
|
+
"lib/net8.0/Amazon.Lambda.Core.dll": {
|
|
20
|
+
"assemblyVersion": "1.0.0.0",
|
|
21
|
+
"fileVersion": "1.0.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"Amazon.Lambda.RuntimeSupport/1.10.0": {
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"Amazon.Lambda.Core": "2.2.0"
|
|
28
|
+
},
|
|
29
|
+
"runtime": {
|
|
30
|
+
"lib/net8.0/Amazon.Lambda.RuntimeSupport.dll": {
|
|
31
|
+
"assemblyVersion": "1.10.0.0",
|
|
32
|
+
"fileVersion": "1.10.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"libraries": {
|
|
39
|
+
"dotnet-bootstrap/1.0.0": {
|
|
40
|
+
"type": "project",
|
|
41
|
+
"serviceable": false,
|
|
42
|
+
"sha512": ""
|
|
43
|
+
},
|
|
44
|
+
"Amazon.Lambda.Core/2.2.0": {
|
|
45
|
+
"type": "package",
|
|
46
|
+
"serviceable": true,
|
|
47
|
+
"sha512": "sha512-DHqKeD1CYocP0t1dJC/NaXfu+5k6AoqnQ1Hlu/J2mXpLpCyeJfY+tIqT5fpruDarUlU0NtdIH8zSkCjeinyb1A==",
|
|
48
|
+
"path": "amazon.lambda.core/2.2.0",
|
|
49
|
+
"hashPath": "amazon.lambda.core.2.2.0.nupkg.sha512"
|
|
50
|
+
},
|
|
51
|
+
"Amazon.Lambda.RuntimeSupport/1.10.0": {
|
|
52
|
+
"type": "package",
|
|
53
|
+
"serviceable": true,
|
|
54
|
+
"sha512": "sha512-J1NdaUV24sWALmCjzJJ6vezskeeH2NxJU7ao86rgdzW+AcgnhYjIULuKQNAx6fTl8AP/8acFsq7Jp7k156hh4A==",
|
|
55
|
+
"path": "amazon.lambda.runtimesupport/1.10.0",
|
|
56
|
+
"hashPath": "amazon.lambda.runtimesupport.1.10.0.nupkg.sha512"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeOptions": {
|
|
3
|
+
"tfm": "net8.0",
|
|
4
|
+
"framework": {
|
|
5
|
+
"name": "Microsoft.NETCore.App",
|
|
6
|
+
"version": "8.0.0"
|
|
7
|
+
},
|
|
8
|
+
"configProperties": {
|
|
9
|
+
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
10
|
+
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -30914,62 +30914,65 @@ var require_dist_cjs59 = __commonJS({
|
|
|
30914
30914
|
// support/ssr-warmer/index.ts
|
|
30915
30915
|
var import_client_lambda = __toESM(require_dist_cjs59(), 1);
|
|
30916
30916
|
var lambda = new import_client_lambda.LambdaClient({});
|
|
30917
|
-
var
|
|
30918
|
-
var CONCURRENCY = parseInt(process.env.CONCURRENCY);
|
|
30917
|
+
var warmParams = JSON.parse(process.env.WARM_PARAMS);
|
|
30919
30918
|
function generateUniqueId() {
|
|
30920
30919
|
return Math.random().toString(36).slice(2, 8);
|
|
30921
30920
|
}
|
|
30922
30921
|
async function handler(_event, context) {
|
|
30923
30922
|
const warmerId = `warmer-${generateUniqueId()}`;
|
|
30924
|
-
|
|
30925
|
-
|
|
30926
|
-
|
|
30927
|
-
|
|
30928
|
-
|
|
30929
|
-
|
|
30930
|
-
|
|
30931
|
-
|
|
30932
|
-
|
|
30933
|
-
|
|
30934
|
-
|
|
30935
|
-
|
|
30936
|
-
|
|
30937
|
-
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
|
|
30923
|
+
for (const warmParam of warmParams) {
|
|
30924
|
+
const { concurrency: CONCURRENCY, function: FUNCTION_NAME } = warmParam;
|
|
30925
|
+
console.log({
|
|
30926
|
+
event: "warmer invoked",
|
|
30927
|
+
functionName: FUNCTION_NAME,
|
|
30928
|
+
concurrency: CONCURRENCY,
|
|
30929
|
+
warmerId
|
|
30930
|
+
});
|
|
30931
|
+
const ret = await Promise.all(
|
|
30932
|
+
Array.from({ length: CONCURRENCY }, (_v, i) => i).map((i) => {
|
|
30933
|
+
try {
|
|
30934
|
+
return lambda.send(
|
|
30935
|
+
new import_client_lambda.InvokeCommand({
|
|
30936
|
+
FunctionName: FUNCTION_NAME,
|
|
30937
|
+
InvocationType: "RequestResponse",
|
|
30938
|
+
Payload: JSON.stringify({
|
|
30939
|
+
type: "warmer",
|
|
30940
|
+
warmerId,
|
|
30941
|
+
index: i,
|
|
30942
|
+
concurrency: CONCURRENCY,
|
|
30943
|
+
delay: 75
|
|
30944
|
+
})
|
|
30943
30945
|
})
|
|
30944
|
-
|
|
30946
|
+
);
|
|
30947
|
+
} catch (e) {
|
|
30948
|
+
console.error(`failed to warm up #${i}`, e);
|
|
30949
|
+
}
|
|
30950
|
+
})
|
|
30951
|
+
);
|
|
30952
|
+
const warmedServerIds = [];
|
|
30953
|
+
ret.forEach((r, i) => {
|
|
30954
|
+
if (r?.StatusCode !== 200 || !r?.Payload) {
|
|
30955
|
+
console.error(`failed to warm up #${i}:`, r?.Payload?.toString());
|
|
30956
|
+
return;
|
|
30957
|
+
}
|
|
30958
|
+
const payloadString = r.Payload.transformToString();
|
|
30959
|
+
if (payloadString) {
|
|
30960
|
+
const payload = JSON.parse(
|
|
30961
|
+
r.Payload.transformToString()
|
|
30945
30962
|
);
|
|
30946
|
-
|
|
30947
|
-
|
|
30948
|
-
|
|
30949
|
-
|
|
30950
|
-
|
|
30951
|
-
|
|
30952
|
-
|
|
30953
|
-
|
|
30954
|
-
|
|
30955
|
-
|
|
30956
|
-
|
|
30957
|
-
|
|
30958
|
-
|
|
30959
|
-
const payload = JSON.parse(
|
|
30960
|
-
r.Payload.transformToString()
|
|
30961
|
-
);
|
|
30962
|
-
warmedServerIds.push(payload.serverId);
|
|
30963
|
-
} else {
|
|
30964
|
-
warmedServerIds.push("unknown");
|
|
30965
|
-
}
|
|
30966
|
-
});
|
|
30967
|
-
console.log({
|
|
30968
|
-
event: "warmer result",
|
|
30969
|
-
sent: CONCURRENCY,
|
|
30970
|
-
success: warmedServerIds.length,
|
|
30971
|
-
uniqueServersWarmed: [...new Set(warmedServerIds)].length
|
|
30972
|
-
});
|
|
30963
|
+
warmedServerIds.push(payload.serverId);
|
|
30964
|
+
} else {
|
|
30965
|
+
warmedServerIds.push("unknown");
|
|
30966
|
+
}
|
|
30967
|
+
});
|
|
30968
|
+
console.log({
|
|
30969
|
+
event: "warmer result",
|
|
30970
|
+
sent: CONCURRENCY,
|
|
30971
|
+
name: FUNCTION_NAME,
|
|
30972
|
+
success: warmedServerIds.length,
|
|
30973
|
+
uniqueServersWarmed: [...new Set(warmedServerIds)].length
|
|
30974
|
+
});
|
|
30975
|
+
}
|
|
30973
30976
|
}
|
|
30974
30977
|
export {
|
|
30975
30978
|
handler
|