@goldstack/template-lambda-api 0.3.77 → 0.4.3

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": "@goldstack/template-lambda-api",
3
- "version": "0.3.77",
3
+ "version": "0.4.3",
4
4
  "description": "Companion for project templates for deploying Lambdas as a REST API",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@goldstack/infra": "0.3.24",
49
49
  "@goldstack/infra-aws": "0.3.29",
50
- "@goldstack/utils-aws-lambda": "0.1.5",
50
+ "@goldstack/utils-aws-lambda": "0.1.6",
51
51
  "@goldstack/utils-cli": "0.2.8",
52
52
  "@goldstack/utils-config": "0.3.23",
53
53
  "@goldstack/utils-docker": "0.3.25",
@@ -57,8 +57,8 @@
57
57
  "@goldstack/utils-s3-deployment": "0.3.36",
58
58
  "@goldstack/utils-sh": "0.4.22",
59
59
  "@goldstack/utils-template": "0.3.24",
60
- "@goldstack/utils-terraform": "0.3.36",
61
- "@goldstack/utils-terraform-aws": "0.3.36",
60
+ "@goldstack/utils-terraform": "0.3.37",
61
+ "@goldstack/utils-terraform-aws": "0.3.37",
62
62
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.0-rc.1",
63
63
  "archiver": "^5.0.0",
64
64
  "esbuild": "^0.14.5",
@@ -11,13 +11,23 @@ export const generateLambdaConfig = (
11
11
  deployment: LambdaApiDeployment,
12
12
  config: LambdaConfig[]
13
13
  ): LambdaRoutesConfig => {
14
- return config.reduce((last, curr) => {
15
- last[curr.route] = {
14
+ return config.reduce((last, curr, index) => {
15
+ last[`${curr.route}${index}`] = {
16
16
  function_name: generateFunctionName(
17
17
  deployment.configuration.lambdaNamePrefix,
18
18
  curr
19
19
  ),
20
+ route: curr.route,
20
21
  };
21
22
  return last;
22
23
  }, {});
23
24
  };
25
+
26
+ export const validateDeployment = (config: LambdaRoutesConfig): boolean => {
27
+ let valid = true;
28
+ for (const e of Object.entries(config)) {
29
+ valid = valid && e[0].length > 0;
30
+ valid = valid && !!e[1].function_name && e[1].function_name.length > 0;
31
+ }
32
+ return valid;
33
+ };
@@ -13,7 +13,10 @@ import {
13
13
  LambdaApiDeployment,
14
14
  } from './types/LambdaApiPackage';
15
15
  import { readLambdaConfig } from '@goldstack/utils-aws-lambda';
16
- import { generateLambdaConfig } from './generateLambdaConfig';
16
+ import {
17
+ generateLambdaConfig,
18
+ validateDeployment,
19
+ } from './generateLambdaConfig';
17
20
  import { defaultRoutesPath } from './templateLambdaConsts';
18
21
  import { buildLambdas } from './templateLambdaApiBuild';
19
22
 
@@ -52,6 +55,7 @@ export const run = async (args: string[]): Promise<void> => {
52
55
  config.deployments = config.deployments.map((e) => {
53
56
  const lambdasConfigs = generateLambdaConfig(e, lambdaRoutes);
54
57
  e.configuration.lambdas = lambdasConfigs;
58
+ validateDeployment(e.configuration.lambdas);
55
59
  return e;
56
60
  });
57
61
  writePackageConfig(config);
@@ -37,6 +37,7 @@ export type CorsHeader = string;
37
37
 
38
38
  export interface LambdaRouteConfig {
39
39
  function_name: string;
40
+ route: string;
40
41
  }
41
42
 
42
43
  export type LambdaRoutesConfig = {