@openhi/constructs 0.0.29 → 0.0.30

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/lib/index.mjs CHANGED
@@ -1208,13 +1208,13 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1208
1208
  _OpenHiDataService.SERVICE_TYPE = "data";
1209
1209
  var OpenHiDataService = _OpenHiDataService;
1210
1210
 
1211
- // src/data/lambda/rest-api-lambda.ts
1211
+ // src/data/lambda/cors-options-lambda.ts
1212
1212
  import fs2 from "fs";
1213
1213
  import path2 from "path";
1214
1214
  import { Runtime as Runtime2 } from "aws-cdk-lib/aws-lambda";
1215
1215
  import { NodejsFunction as NodejsFunction2 } from "aws-cdk-lib/aws-lambda-nodejs";
1216
1216
  import { Construct as Construct4 } from "constructs";
1217
- var HANDLER_NAME2 = "rest-api-lambda.handler.js";
1217
+ var HANDLER_NAME2 = "cors-options-lambda.handler.js";
1218
1218
  function resolveHandlerEntry2(dirname) {
1219
1219
  const sameDir = path2.join(dirname, HANDLER_NAME2);
1220
1220
  if (fs2.existsSync(sameDir)) {
@@ -1223,12 +1223,38 @@ function resolveHandlerEntry2(dirname) {
1223
1223
  const fromLib = path2.join(dirname, "..", "..", "..", "lib", HANDLER_NAME2);
1224
1224
  return fromLib;
1225
1225
  }
1226
- var RestApiLambda = class extends Construct4 {
1227
- constructor(scope, props) {
1228
- super(scope, "rest-api-lambda");
1226
+ var CorsOptionsLambda = class extends Construct4 {
1227
+ constructor(scope, id = "cors-options-lambda") {
1228
+ super(scope, id);
1229
1229
  this.lambda = new NodejsFunction2(this, "handler", {
1230
1230
  entry: resolveHandlerEntry2(__dirname),
1231
1231
  runtime: Runtime2.NODEJS_LATEST,
1232
+ memorySize: 128
1233
+ });
1234
+ }
1235
+ };
1236
+
1237
+ // src/data/lambda/rest-api-lambda.ts
1238
+ import fs3 from "fs";
1239
+ import path3 from "path";
1240
+ import { Runtime as Runtime3 } from "aws-cdk-lib/aws-lambda";
1241
+ import { NodejsFunction as NodejsFunction3 } from "aws-cdk-lib/aws-lambda-nodejs";
1242
+ import { Construct as Construct5 } from "constructs";
1243
+ var HANDLER_NAME3 = "rest-api-lambda.handler.js";
1244
+ function resolveHandlerEntry3(dirname) {
1245
+ const sameDir = path3.join(dirname, HANDLER_NAME3);
1246
+ if (fs3.existsSync(sameDir)) {
1247
+ return sameDir;
1248
+ }
1249
+ const fromLib = path3.join(dirname, "..", "..", "..", "lib", HANDLER_NAME3);
1250
+ return fromLib;
1251
+ }
1252
+ var RestApiLambda = class extends Construct5 {
1253
+ constructor(scope, props) {
1254
+ super(scope, "rest-api-lambda");
1255
+ this.lambda = new NodejsFunction3(this, "handler", {
1256
+ entry: resolveHandlerEntry3(__dirname),
1257
+ runtime: Runtime3.NODEJS_LATEST,
1232
1258
  memorySize: 1024,
1233
1259
  environment: {
1234
1260
  DYNAMO_TABLE_NAME: props.dynamoTableName,
@@ -1384,17 +1410,22 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
1384
1410
  })
1385
1411
  );
1386
1412
  const integration = new HttpLambdaIntegration("lambda-integration", lambda);
1413
+ const { lambda: optionsLambda } = new CorsOptionsLambda(this);
1414
+ const optionsIntegration = new HttpLambdaIntegration(
1415
+ "options-integration",
1416
+ optionsLambda
1417
+ );
1387
1418
  const noAuth = new HttpNoneAuthorizer();
1388
1419
  new HttpRoute(this, "options-route-root", {
1389
1420
  httpApi: this.rootHttpApi,
1390
1421
  routeKey: HttpRouteKey.with("/", HttpMethod.OPTIONS),
1391
- integration,
1422
+ integration: optionsIntegration,
1392
1423
  authorizer: noAuth
1393
1424
  });
1394
1425
  new HttpRoute(this, "options-route-proxy", {
1395
1426
  httpApi: this.rootHttpApi,
1396
1427
  routeKey: HttpRouteKey.with("/{proxy+}", HttpMethod.OPTIONS),
1397
- integration,
1428
+ integration: optionsIntegration,
1398
1429
  authorizer: noAuth
1399
1430
  });
1400
1431
  new HttpRoute(this, "proxy-route-root", {