@@ -67,11 +67,9 @@ export class HtsgetLambda extends Construct {
6767 constructor ( scope : Construct , id : string , props : HtsgetLambdaProps ) {
6868 super ( scope , id ) ;
6969
70- if ( props . htsgetConfig == undefined ) {
71- props . htsgetConfig = {
72- locations : [ ] ,
73- } ;
74- }
70+ props . htsgetConfig ??= {
71+ locations : [ ] ,
72+ } ;
7573
7674 let httpApi : IHttpApi ;
7775 if ( props . httpApi !== undefined ) {
@@ -95,6 +93,8 @@ export class HtsgetLambda extends Construct {
9593 lambdaRole = this . createRole ( id ) ;
9694 }
9795
96+ props . buildEnvironment ??= { } ;
97+
9898 const htsgetLambda = new RustFunction ( this , "Function" , {
9999 gitRemote : "https://github.com/umccr/htsget-rs" ,
100100 gitForceClone : props . gitForceClone ,
@@ -105,6 +105,7 @@ export class HtsgetLambda extends Construct {
105105 RUSTFLAGS : "-C target-cpu=neoverse-n1" ,
106106 CARGO_PROFILE_RELEASE_LTO : "true" ,
107107 CARGO_PROFILE_RELEASE_CODEGEN_UNITS : "1" ,
108+ ...props . buildEnvironment ,
108109 } ,
109110 cargoLambdaFlags : props . cargoLambdaFlags ?? [
110111 this . resolveFeatures ( props . htsgetConfig , props . copyTestData ?? false ) ,
@@ -214,7 +215,7 @@ export class HtsgetLambda extends Construct {
214215 const latestCommit = exec ( "git" , [
215216 "ls-remote" ,
216217 gitRemote ,
217- gitReference || "HEAD" ,
218+ gitReference ?? "HEAD" ,
218219 ] )
219220 . stdout . toString ( )
220221 . split ( / ( \s + ) / ) [ 0 ] ;
@@ -425,14 +426,14 @@ export class HtsgetLambda extends Construct {
425426 bucket ?: Bucket ,
426427 privateKey ?: Secret ,
427428 publicKey ?: Secret ,
428- ) : { [ key : string ] : string } {
429+ ) : Record < string , string > {
429430 const toHtsgetEnv = ( value : unknown ) => {
430431 return JSON . stringify ( value )
431432 . replaceAll ( new RegExp ( / " ( ) * : ( ) * / g) , "=" )
432433 . replaceAll ( '"' , "" ) ;
433434 } ;
434435
435- const out : { [ key : string ] : string | undefined } = { } ;
436+ const out : Record < string , string | undefined > = { } ;
436437 const locations = config . locations ?? [ ] ;
437438
438439 if ( bucket !== undefined ) {
@@ -463,25 +464,25 @@ export class HtsgetLambda extends Construct {
463464 if (
464465 locationsEnv == "[]" &&
465466 ( config . environment_override === undefined ||
466- config . environment_override [ " HTSGET_LOCATIONS" ] === undefined )
467+ config . environment_override . HTSGET_LOCATIONS === undefined )
467468 ) {
468469 throw new Error (
469470 "no locations configured, htsget-rs wouldn't be able to access any files!" ,
470471 ) ;
471472 }
472473
473- out [ " HTSGET_LOCATIONS" ] = locationsEnv ;
474- out [ " HTSGET_TICKET_SERVER_CORS_ALLOW_CREDENTIALS" ] =
474+ out . HTSGET_LOCATIONS = locationsEnv ;
475+ out . HTSGET_TICKET_SERVER_CORS_ALLOW_CREDENTIALS =
475476 corsConfig ?. allowCredentials ?. toString ( ) ;
476- out [ "HTSGET_TICKET_SERVER_CORS_ALLOW_HEADERS" ] =
477- `[${ corsConfig ?. allowHeaders ?. join ( "," ) as string } ]` ;
478- out [ "HTSGET_TICKET_SERVER_CORS_ALLOW_METHODS" ] =
479- `[${ corsConfig ?. allowMethods ?. join ( "," ) as string } ]` ;
480- out [ "HTSGET_TICKET_SERVER_CORS_ALLOW_ORIGINS" ] =
481- `[${ corsConfig ?. allowOrigins ?. join ( "," ) as string } ]` ;
482- out [ "HTSGET_TICKET_SERVER_CORS_EXPOSE_HEADERS" ] =
483- `[${ corsConfig ?. exposeHeaders ?. join ( "," ) as string } ]` ;
484- out [ " HTSGET_TICKET_SERVER_CORS_MAX_AGE" ] = corsConfig ?. maxAge
477+ // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
478+ out . HTSGET_TICKET_SERVER_CORS_ALLOW_HEADERS = `[${ corsConfig ?. allowHeaders ?. join ( "," ) as string } ]` ;
479+ // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
480+ out . HTSGET_TICKET_SERVER_CORS_ALLOW_METHODS = `[${ corsConfig ?. allowMethods ?. join ( "," ) as string } ]` ;
481+ // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
482+ out . HTSGET_TICKET_SERVER_CORS_ALLOW_ORIGINS = `[${ corsConfig ?. allowOrigins ?. join ( "," ) as string } ]` ;
483+ // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
484+ out . HTSGET_TICKET_SERVER_CORS_EXPOSE_HEADERS = `[${ corsConfig ?. exposeHeaders ?. join ( "," ) as string } ]` ;
485+ out . HTSGET_TICKET_SERVER_CORS_MAX_AGE = corsConfig ?. maxAge
485486 ?. toSeconds ( )
486487 . toString ( ) ;
487488
@@ -499,6 +500,6 @@ export class HtsgetLambda extends Construct {
499500 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
500501 ( out [ key ] == `[undefined]` || out [ key ] == "[]" ) && delete out [ key ] ,
501502 ) ;
502- return out as { [ key : string ] : string } ;
503+ return out as Record < string , string > ;
503504 }
504505}
0 commit comments