Skip to content

Commit

Permalink
Validate the environment parses properly in zod.
Browse files Browse the repository at this point in the history
Part of #1.
  • Loading branch information
jkomoros committed Jun 17, 2023
1 parent 0bc6a29 commit 5d3810c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
z
} from 'zod';

const environment = z.object({
export const environment = z.object({
openai_api_key: z.optional(z.string())
}).catchall(z.string());

Expand Down
6 changes: 5 additions & 1 deletion tools/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import {
Garden
} from '../src/garden.js';

import {
environment
} from '../src/types.js';

import * as fs from 'fs';

const ENVIRONMENT_PATH = 'environment.SECRET.json';

const main = () => {
const data = fs.readFileSync(ENVIRONMENT_PATH).toString();
const env = JSON.parse(data);
const env = environment.parse(JSON.parse(data));
const garden = new Garden(env);
console.log(garden);
};
Expand Down

0 comments on commit 5d3810c

Please sign in to comment.