Package: effect
Module: Config
Creates a config for a URL value parsed from a string.
When to use
Use to read configuration values that must be valid URL strings.
Details
This is a shortcut for Config.schema(Schema.URL, name).
Gotchas
Fails if the string cannot be parsed by the URL constructor.
Example (Reading a URL)
import { Config, ConfigProvider, Effect } from "effect"
const program = Effect.gen(function*() {
const url = yield* Config.url("URL")
console.log(url)
})
const provider = ConfigProvider.fromEnv({
env: {
URL: "https://example.com"
}
})
Effect.runSync(
program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
)
// Output:
// URL {
// href: 'https://example.com/',
// origin: 'https://example.com',
// protocol: 'https:',
// username: '',
// password: '',
// host: 'example.com',
// hostname: 'example.com',
// port: '',
// pathname: '/',
// search: '',
// searchParams: URLSearchParams {},
// hash: ''
// }
See
schema for decoding configuration values with a custom codecSignature
declare const url: (name?: string) => Config<URL>
Since v3.11.0