Skip to main content
NexusConfig holds every value a NexusClient is created with. Its properties are init-only, so a configuration cannot change after the client has it.

Field reference

Environment name

The .NET environment name (Development, Staging, Production) comes from DOTNET_ENVIRONMENT or ASPNETCORE_ENVIRONMENT - DOTNET_ENVIRONMENT wins when both are set with WebApplication.CreateBuilder - or from --environment, and is Production when none is set. The host reads it when the builder is created, before any configuration source is added, so set it as a real environment variable on the process or pod. A Nexus config named ASPNETCORE_ENVIRONMENT arrives after that moment and changes nothing. See Microsoft’s environments documentation.

Service endpoint

With BaseUrl unset or empty, the client reads the endpoint from WESTYX_SERVICE_ENDPOINT (NexusConfig.ServiceEndpointEnvironmentVariable) when it is created. westyx dev run sets the variable for the script’s service, so together with a developer session an application started by it needs neither an endpoint nor a key:
  • A BaseUrl you set always wins - in NexusConfig and in NexusOptions alike.
  • The variable is trimmed, and a value empty after trimming counts as unset.
  • It is validated like the property - https, or http on loopback only - and an error about its value names WESTYX_SERVICE_ENDPOINT rather than BaseUrl.
  • With neither set, CreateAsync and AddWestyxNexus throw ArgumentException naming both.
  • The configuration binder does not map the variable onto Nexus:BaseUrl; the client reads it directly, so the rule holds with or without dependency injection.

Validation

A value that cannot be meant is rejected at construction with NexusConfigException, which carries the offending property in Option:
null selects the default on every optional field, so a default is always expressible without passing a value that means something else.

API key types

Calling GetSecret(...) with a public key throws NexusPublicKeyException.

Where to keep the API key

Anywhere IConfiguration already reads - user secrets in development, environment variables, Azure Key Vault, AWS Secrets Manager, your existing secrets pipeline - but not appsettings.json, which is committed. The SDK never logs the raw key.

Logging a NexusConfig

NexusConfig.ApiKey and NexusOptions.ApiKey carry [JsonIgnore] and [IgnoreDataMember], so a configuration serialized through System.Text.Json or Newtonsoft.Json contains the base URL and not the key. Serilog’s destructuring operator honours neither. {@Config} walks public properties directly, so log a config as {Config}:
The same applies to an options type of your own: a record prints its properties from the compiler-generated ToString(), so a secret bound into one reaches any log that prints it. Use a class for a type that holds a secret.

Choosing the TTL

The TTL is a tradeoff between staleness window and redundant network traffic. With SSE enabled, changes propagate in milliseconds regardless of the TTL - the TTL only matters as a safety net if the stream falls back.