sst 2.0.0-rc.48 → 2.0.0-rc.49

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.
@@ -1,4 +1,4 @@
1
- export const transform = (program) => program.command("transform <mod>", "Apply a transform on your SST app", (yargs) => yargs.positional("mod", {
1
+ export const transform = (program) => program.command("transform <mod>", "Apply a transform to your SST app", (yargs) => yargs.positional("mod", {
2
2
  type: "string",
3
3
  describe: "Name of the transform",
4
4
  demandOption: true,
package/constructs/App.js CHANGED
@@ -441,7 +441,7 @@ export class App extends cdk.App {
441
441
  fs.mkdirSync(typesPath, {
442
442
  recursive: true,
443
443
  });
444
- fs.writeFileSync(`${typesPath}/index.ts`, [
444
+ fs.appendFileSync(`${typesPath}/index.ts`, [
445
445
  `import "sst/node/config";`,
446
446
  `declare module "sst/node/config" {`,
447
447
  ` export interface ConfigTypes {`,
@@ -465,7 +465,7 @@ export class App extends cdk.App {
465
465
  const className = c.constructor.name;
466
466
  const id = c.id;
467
467
  // Case 1: variable does not have properties, ie. Secrets and Parameters
468
- fs.writeFileSync(`${typesPath}/${className}-${id}.ts`, (binding.variables[0] === "."
468
+ fs.appendFileSync(`${typesPath}/index.ts`, (binding.variables[0] === "."
469
469
  ? [
470
470
  `import "sst/node/${binding.clientPackage}";`,
471
471
  `declare module "sst/node/${binding.clientPackage}" {`,
@@ -35,7 +35,7 @@ export class AstroSite extends SsrSite {
35
35
  super.validateBuildOutput();
36
36
  }
37
37
  createFunctionForRegional() {
38
- const { defaults, environment } = this.props;
38
+ const { defaults, environment, bind } = this.props;
39
39
  // Bundle code
40
40
  const handler = this.isPlaceholder
41
41
  ? path.resolve(__dirname, "../support/ssr-site-function-stub/index.handler")
@@ -44,6 +44,7 @@ export class AstroSite extends SsrSite {
44
44
  const fn = new Function(this, `ServerFunction`, {
45
45
  description: "Server handler",
46
46
  handler,
47
+ bind,
47
48
  logRetention: "three_days",
48
49
  runtime: "nodejs16.x",
49
50
  memorySize: defaults?.function?.memorySize || "512 MB",
@@ -71,7 +72,9 @@ export class AstroSite extends SsrSite {
71
72
  // of the "core server build" along with our custom Lamba server handler.
72
73
  const outputPath = path.resolve(path.join(this.sstBuildDir, `AstroSiteFunction-${this.node.id}-${this.node.addr}`));
73
74
  const result = esbuild.buildSync({
74
- entryPoints: [path.join(this.props.path, this.buildConfig.serverBuildOutputFile)],
75
+ entryPoints: [
76
+ path.join(this.props.path, this.buildConfig.serverBuildOutputFile),
77
+ ],
75
78
  target: "esnext",
76
79
  format: "esm",
77
80
  platform: "node",
@@ -21,6 +21,18 @@ export interface SsrDomainProps extends BaseSiteDomainProps {
21
21
  export interface SsrCdkDistributionProps extends BaseSiteCdkDistributionProps {
22
22
  }
23
23
  export interface SsrSiteProps {
24
+ /**
25
+ * Bind resources for the function
26
+ *
27
+ * @example
28
+ * ```js
29
+ * new Function(stack, "Function", {
30
+ * handler: "src/function.handler",
31
+ * bind: [STRIPE_KEY, bucket],
32
+ * })
33
+ * ```
34
+ */
35
+ bind?: SSTConstruct[];
24
36
  /**
25
37
  * The SSR function is deployed to Lambda in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge.
26
38
  * @default false
@@ -283,9 +283,9 @@ export class SsrSite extends Construct {
283
283
  const app = this.node.root;
284
284
  const script = path.resolve(__dirname, "../support/base-site-archiver.mjs");
285
285
  const fileSizeLimit = app.isRunningSSTTest()
286
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
287
- // @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
288
- ? this.props.sstTestFileSizeLimitOverride || 200
286
+ ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
287
+ // @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
288
+ this.props.sstTestFileSizeLimitOverride || 200
289
289
  : 200;
290
290
  const result = spawn.sync("node", [
291
291
  script,
@@ -348,11 +348,13 @@ export class SsrSite extends Construct {
348
348
  ];
349
349
  }
350
350
  createS3AssetFileOptionsForStub() {
351
- return [{
351
+ return [
352
+ {
352
353
  exclude: "*",
353
354
  include: "*",
354
355
  cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
355
- }];
356
+ },
357
+ ];
356
358
  }
357
359
  createS3Bucket() {
358
360
  const { cdk } = this.props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.48",
3
+ "version": "2.0.0-rc.49",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/sst.mjs CHANGED
@@ -6749,7 +6749,7 @@ var update = (program2) => program2.command(
6749
6749
  // src/cli/commands/transform.ts
6750
6750
  var transform = (program2) => program2.command(
6751
6751
  "transform <mod>",
6752
- "Apply a transform on your SST app",
6752
+ "Apply a transform to your SST app",
6753
6753
  (yargs2) => yargs2.positional("mod", {
6754
6754
  type: "string",
6755
6755
  describe: "Name of the transform",