Skip to content

Commit

Permalink
refactor: extract honoEnv call to a variable
Browse files Browse the repository at this point in the history
Improve readability by storing honoEnv result to a variable before use.
  • Loading branch information
gentlementlegen committed Nov 1, 2024
1 parent 1aa8f0c commit f30dbb5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sdk/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ export function createPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents
}

let env: TEnv;
const honoEnvironment = honoEnv(ctx);
if (pluginOptions.envSchema) {
try {
env = Value.Decode(pluginOptions.envSchema, Value.Default(pluginOptions.envSchema, honoEnv(ctx)));
env = Value.Decode(pluginOptions.envSchema, Value.Default(pluginOptions.envSchema, honoEnvironment));
} catch (e) {
console.dir(...Value.Errors(pluginOptions.envSchema, ctx.env), { depth: null });
console.dir(...Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
throw e;
}
} else {
Expand Down

0 comments on commit f30dbb5

Please sign in to comment.