Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja committed Aug 31, 2024
1 parent 28caa5b commit 70125ec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { type Static, type TObject, Type } from "@sinclair/typebox";
import { Value } from "@sinclair/typebox/value";

function parseEnv<T extends TObject>(schema: T, env: Record<string, string | undefined>): Static<T> {
function parseEnv<T extends TObject>(
schema: T,
env: Record<string, string | undefined>,
): Static<T> {
const cleaned = Object.fromEntries(
Object.entries(env).filter(([key]) => Object.keys(schema.properties).includes(key)),
)
Object.entries(env).filter(([key]) =>
Object.keys(schema.properties).includes(key),
),
);
const converted = Value.Convert(schema, Value.Default(schema, cleaned));
const isValid = Value.Check(schema, converted);
if (!isValid) {
Expand Down

0 comments on commit 70125ec

Please sign in to comment.