Skip to content

Commit 6d5684f

Browse files
committed
Hard code variant map DO NOT COMMIT
1 parent f0ce917 commit 6d5684f

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

lambdas/supplier-allocator/src/config/__tests__/env.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

lambdas/supplier-allocator/src/config/env.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from "zod";
22

3+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
34
const LetterVariantSchema = z.record(
45
z.string(),
56
z.object({
@@ -10,14 +11,30 @@ const LetterVariantSchema = z.record(
1011
);
1112
export 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+
1322
const 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

2130
export 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+
};

0 commit comments

Comments
 (0)