@@ -485,7 +485,7 @@ export default class Apigw {
485
485
486
486
const unboundSecretIds = await this . getUnboundSecretIds ( {
487
487
usagePlanId : usagePlan . usagePlanId ,
488
- secretIds : secrets . secretIds ,
488
+ secretIds : secrets . secretIds ! ,
489
489
} ) ;
490
490
491
491
if ( unboundSecretIds . length > 0 ) {
@@ -654,7 +654,7 @@ export default class Apigw {
654
654
path,
655
655
method,
656
656
} : {
657
- serviceId : string ;
657
+ serviceId ? : string ;
658
658
path : string ;
659
659
method : string ;
660
660
} ) {
@@ -704,42 +704,47 @@ export default class Apigw {
704
704
705
705
async createOrUpdateApi ( { serviceId, endpoint, environment, created } : CreateOrUpdateApiInputs ) {
706
706
// compatibility for secret auth config depends on auth & usagePlan
707
- const authType = endpoint . auth ? 'SECRET' : endpoint . authType || 'NONE' ;
708
- const businessType = endpoint . businessType || 'NORMAL' ;
707
+ const authType = endpoint ? .auth ? 'SECRET' : endpoint ? .authType ?? 'NONE' ;
708
+ const businessType = endpoint ? .businessType ?? 'NORMAL' ;
709
709
const output : ApiDeployerOutputs = {
710
- path : endpoint . path ,
711
- method : endpoint . method ,
712
- apiName : endpoint . apiName || 'index' ,
710
+ path : endpoint ? .path ,
711
+ method : endpoint ? .method ,
712
+ apiName : endpoint ? .apiName || 'index' ,
713
713
created : true ,
714
714
authType : authType ,
715
715
businessType : businessType ,
716
- isBase64Encoded : endpoint . isBase64Encoded === true ,
716
+ isBase64Encoded : endpoint ? .isBase64Encoded === true ,
717
717
} ;
718
- if ( endpoint . authRelationApiId ) {
718
+ if ( endpoint ? .authRelationApiId ) {
719
719
output . authRelationApiId = endpoint . authRelationApiId ;
720
720
}
721
721
722
722
const apiInputs = {
723
- protocol : endpoint . protocol || 'HTTP' ,
723
+ protocol : endpoint ? .protocol ?? 'HTTP' ,
724
724
serviceId : serviceId ,
725
- apiName : endpoint . apiName || 'index' ,
726
- apiDesc : endpoint . description ,
725
+ apiName : endpoint ? .apiName ?? 'index' ,
726
+ apiDesc : endpoint ? .description ,
727
727
apiType : 'NORMAL' ,
728
728
authType : authType ,
729
- apiBusinessType : endpoint . businessType || 'NORMAL' ,
730
- serviceType : endpoint . serviceType || 'SCF' ,
729
+ apiBusinessType : endpoint ? .businessType ?? 'NORMAL' ,
730
+ serviceType : endpoint ? .serviceType ?? 'SCF' ,
731
731
requestConfig : {
732
- path : endpoint . path ,
733
- method : endpoint . method ,
732
+ path : endpoint ? .path ,
733
+ method : endpoint ? .method ,
734
734
} ,
735
- serviceTimeout : endpoint . serviceTimeout || 15 ,
736
- responseType : endpoint . responseType || 'HTML' ,
737
- enableCORS : endpoint . enableCORS === true ,
738
- isBase64Encoded : endpoint . isBase64Encoded === true ,
735
+ serviceTimeout : endpoint ? .serviceTimeout ?? 15 ,
736
+ responseType : endpoint ? .responseType ?? 'HTML' ,
737
+ enableCORS : endpoint ? .enableCORS === true ,
738
+ isBase64Encoded : endpoint ? .isBase64Encoded === true ,
739
739
isBase64Trigger : undefined as undefined | boolean ,
740
- base64EncodedTriggerRules : undefined as undefined | string [ ] ,
741
- oauthConfig : endpoint . oauthConfig ,
742
- authRelationApiId : endpoint . authRelationApiId ,
740
+ base64EncodedTriggerRules : undefined as
741
+ | undefined
742
+ | {
743
+ name : string ;
744
+ value : string [ ] ;
745
+ } [ ] ,
746
+ oauthConfig : endpoint ?. oauthConfig ,
747
+ authRelationApiId : endpoint ?. authRelationApiId ,
743
748
} ;
744
749
745
750
this . marshalApiInput ( endpoint , apiInputs ) ;
@@ -749,20 +754,20 @@ export default class Apigw {
749
754
InternalDomain ?: string ;
750
755
} ;
751
756
752
- if ( endpoint . apiId ) {
753
- apiDetail = await this . getApiById ( { serviceId, apiId : endpoint . apiId } ) ;
757
+ if ( endpoint ? .apiId ) {
758
+ apiDetail = await this . getApiById ( { serviceId : serviceId ! , apiId : endpoint . apiId } ) ;
754
759
}
755
760
756
761
if ( ! apiDetail ! ) {
757
762
apiDetail = await this . getApiByPathAndMethod ( {
758
- serviceId,
759
- path : endpoint . path ,
760
- method : endpoint . method ,
763
+ serviceId : serviceId ! ,
764
+ path : endpoint ? .path ! ,
765
+ method : endpoint ? .method ! ,
761
766
} ) ;
762
767
}
763
768
764
- if ( apiDetail ) {
765
- console . log ( `Api method ${ endpoint . method } , path ${ endpoint . path } already exist` ) ;
769
+ if ( apiDetail && endpoint ) {
770
+ console . log ( `Api method ${ endpoint ? .method } , path ${ endpoint ? .path } already exist` ) ;
766
771
endpoint . apiId = apiDetail . ApiId ;
767
772
768
773
if ( endpoint . isBase64Encoded && endpoint . isBase64Trigger ) {
@@ -796,7 +801,7 @@ export default class Apigw {
796
801
} ) ;
797
802
output . internalDomain = apiDetail . InternalDomain || '' ;
798
803
799
- if ( endpoint . isBase64Encoded && endpoint . isBase64Trigger ) {
804
+ if ( endpoint ? .isBase64Encoded && endpoint . isBase64Trigger ) {
800
805
apiInputs . isBase64Trigger = endpoint . isBase64Trigger ;
801
806
apiInputs . base64EncodedTriggerRules = endpoint . base64EncodedTriggerRules ;
802
807
}
@@ -810,7 +815,7 @@ export default class Apigw {
810
815
811
816
output . apiName = apiInputs . apiName ;
812
817
813
- if ( endpoint . usagePlan ) {
818
+ if ( endpoint ? .usagePlan ) {
814
819
const usagePlan = await this . bindUsagePlan ( {
815
820
apiId : output . apiId ,
816
821
serviceId,
@@ -837,7 +842,7 @@ export default class Apigw {
837
842
// if exist in state list, set created to be true
838
843
const [ exist ] = oldList . filter (
839
844
( item ) =>
840
- item . method . toLowerCase ( ) === apiConfig . method . toLowerCase ( ) &&
845
+ item ? .method ? .toLowerCase ( ) === apiConfig ? .method ? .toLowerCase ( ) &&
841
846
item . path === apiConfig . path ,
842
847
) ;
843
848
@@ -855,7 +860,7 @@ export default class Apigw {
855
860
if ( authRelationApi ) {
856
861
const [ relativeApi ] = apiList . filter (
857
862
( item ) =>
858
- item . method . toLowerCase ( ) === authRelationApi . method . toLowerCase ( ) &&
863
+ item . method ? .toLowerCase ( ) === authRelationApi . method . toLowerCase ( ) &&
859
864
item . path === authRelationApi . path ,
860
865
) ;
861
866
if ( relativeApi ) {
0 commit comments