File tree Expand file tree Collapse file tree
lambdas/supplier-allocator/src/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ describe("lambdaEnv", () => {
3232 specId : "spec1" ,
3333 priority : 10 ,
3434 } ,
35+ lv2 : {
36+ priority : 10 ,
37+ specId : "spec2" ,
38+ supplierId : "supplier1" ,
39+ } ,
40+ lv3 : {
41+ priority : 10 ,
42+ specId : "spec3" ,
43+ supplierId : "supplier2" ,
44+ } ,
3545 } ,
3646 } ) ;
3747 } ) ;
Original file line number Diff line number Diff line change 11import { z } from "zod" ;
22
3+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34const LetterVariantSchema = z . record (
45 z . string ( ) ,
56 z . object ( {
@@ -10,14 +11,30 @@ const LetterVariantSchema = z.record(
1011) ;
1112export type LetterVariant = z . infer < typeof LetterVariantSchema > ;
1213
14+ const OldLetterVariantSchema = z . record (
15+ z . string ( ) ,
16+ z . object ( {
17+ supplierId : z . string ( ) ,
18+ specId : z . string ( ) ,
19+ } ) ,
20+ ) ;
21+
1322const EnvVarsSchema = z . object ( {
1423 PINO_LOG_LEVEL : z . coerce . string ( ) . optional ( ) ,
1524 VARIANT_MAP : z . string ( ) . transform ( ( str , _ ) => {
1625 const parsed = JSON . parse ( str ) ;
17- return LetterVariantSchema . parse ( parsed ) ;
26+ return OldLetterVariantSchema . parse ( parsed ) ;
1827 } ) ,
1928} ) ;
2029
2130export type EnvVars = z . infer < typeof EnvVarsSchema > ;
2231
23- export const envVars = EnvVarsSchema . parse ( process . env ) ;
32+ const parsedEnvVars = EnvVarsSchema . parse ( process . env ) ;
33+ export const envVars = {
34+ ...parsedEnvVars ,
35+ VARIANT_MAP : {
36+ lv1 : { supplierId : "supplier1" , specId : "spec1" , priority : 10 } ,
37+ lv2 : { supplierId : "supplier1" , specId : "spec2" , priority : 10 } ,
38+ lv3 : { supplierId : "supplier2" , specId : "spec3" , priority : 10 } ,
39+ } ,
40+ } ;
You can’t perform that action at this time.
0 commit comments