@openhi/constructs 0.0.42 → 0.0.43

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
@@ -1124,6 +1124,7 @@ var OpenHiGlobalService = _OpenHiGlobalService;
1124
1124
 
1125
1125
  // src/services/open-hi-rest-api-service.ts
1126
1126
  import {
1127
+ CorsHttpMethod,
1127
1128
  DomainName,
1128
1129
  HttpApi as HttpApi2,
1129
1130
  HttpMethod,
@@ -1140,6 +1141,7 @@ import {
1140
1141
  RecordTarget
1141
1142
  } from "aws-cdk-lib/aws-route53";
1142
1143
  import { ApiGatewayv2DomainProperties } from "aws-cdk-lib/aws-route53-targets";
1144
+ import { Duration as Duration3 } from "aws-cdk-lib/core";
1143
1145
 
1144
1146
  // src/services/open-hi-data-service.ts
1145
1147
  import { Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
@@ -1465,8 +1467,31 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
1465
1467
  userPool,
1466
1468
  { userPoolClients: [userPoolClient] }
1467
1469
  );
1470
+ const { corsPreflight: cors, ...restRootHttpApiProps } = this.props.rootHttpApiProps ?? {};
1471
+ const corsPreflight = cors !== void 0 ? {
1472
+ allowOrigins: cors.allowOrigins,
1473
+ allowMethods: cors.allowMethods ?? [
1474
+ CorsHttpMethod.GET,
1475
+ CorsHttpMethod.HEAD,
1476
+ CorsHttpMethod.POST,
1477
+ CorsHttpMethod.PUT,
1478
+ CorsHttpMethod.PATCH,
1479
+ CorsHttpMethod.DELETE,
1480
+ CorsHttpMethod.OPTIONS
1481
+ ],
1482
+ allowHeaders: cors.allowHeaders ?? [
1483
+ "Content-Type",
1484
+ "Authorization"
1485
+ ],
1486
+ allowCredentials: cors.allowCredentials ?? true,
1487
+ maxAge: cors.maxAge ?? Duration3.days(1),
1488
+ ...cors.exposeHeaders !== void 0 && {
1489
+ exposeHeaders: cors.exposeHeaders
1490
+ }
1491
+ } : void 0;
1468
1492
  const rootHttpApi = new RootHttpApi(this, {
1469
- ...this.props.rootHttpApiProps,
1493
+ ...restRootHttpApiProps,
1494
+ ...corsPreflight !== void 0 && { corsPreflight },
1470
1495
  defaultDomainMapping: {
1471
1496
  domainName,
1472
1497
  mappingKey: void 0