import { Config, Effect } from "effect";
const appConfig = Config.all({
host: Config.string("HOST").pipe(Config.withDefault("localhost")),
port: Config.number("PORT").pipe(Config.withDefault(8080)),
});
const config = Config.all({
app: appConfig,
});
type ConfigType = Config.Config<typeof config>;
// function to load the configuration
async function loadConfig(): Promise<ConfigType> {
return await Effect.runPromise(config); // lint error under 'return'
}
const cfg = await loadConfig();
console.log(cfg);
console.log(cfg.app.port);
import { Config, Effect } from "effect";
const appConfig = Config.all({
host: Config.string("HOST").pipe(Config.withDefault("localhost")),
port: Config.number("PORT").pipe(Config.withDefault(8080)),
});
const config = Config.all({
app: appConfig,
});
type ConfigType = Config.Config<typeof config>;
// function to load the configuration
async function loadConfig(): Promise<ConfigType> {
return await Effect.runPromise(config); // lint error under 'return'
}
const cfg = await loadConfig();
console.log(cfg);
console.log(cfg.app.port);