https://github.com/pandatecham/be-lib-startup-environment-check
Designed to validate essential environment variables during application startup. By checking required configurations, it prevents unexpected behaviors and ensures smooth initialization. Easily integrate this check into your .NET applications to enhance robustness and maintainability.
https://github.com/pandatecham/be-lib-startup-environment-check
Last synced: 3 months ago
JSON representation
Designed to validate essential environment variables during application startup. By checking required configurations, it prevents unexpected behaviors and ensures smooth initialization. Easily integrate this check into your .NET applications to enhance robustness and maintainability.
- Host: GitHub
- URL: https://github.com/pandatecham/be-lib-startup-environment-check
- Owner: PandaTechAM
- Created: 2023-08-23T20:35:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-29T08:44:45.000Z (about 2 years ago)
- Last Synced: 2025-07-22T07:09:21.399Z (6 months ago)
- Language: C#
- Size: 151 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Pandatech.StartupEnvironmentCheck
`Pandatech.StartupEnvironmentCheck` is a lightweight library designed to validate required environment variables at
application startup. It helps ensure that essential configurations are in place, preventing unexpected behaviors or
failures due to missing environment variables.
## Installation
You can install `Pandatech.StartupEnvironmentCheck` via NuGet Package Manager or by using the following command in your
Package Manager Console:
```powershell
Install-Package Pandatech.StartupEnvironmentCheck
```
## Usage
### Validating Environment Variables
You can use the `EnvironmentVariableValidator.ValidateEnvironmentVariables` method to validate required environment
variables. Here's an example:
```csharp
using StartupEnvironmentCheck;
public class Program
{
public static void Main(string[] args)
{
var requiredEnvVars = new List { "DB_CONNECTION_STRING", "API_KEY" };
EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);
// Continue with the rest of the application startup
}
}
```
### Handling Missing Variables
If any required environment variables are missing, a `MissingEnvironmentVariablesException` will be thrown. This
exception includes a detailed message listing the missing variables.
You can catch this exception to log the error or take other appropriate actions:
```csharp
try
{
EnvironmentVariableValidator.ValidateEnvironmentVariables(requiredEnvVars);
}
catch (MissingEnvironmentVariablesException ex)
{
// Log the error or take other actions
}
```
## Contributing
For support, issues, or contributions, please refer to the project's GitHub repository or contact the maintainers.
## License
This project is licensed under the MIT License.