added support for .env file and improved validation

This commit is contained in:
2024-09-14 21:34:21 +03:30
parent 2f2ab5f944
commit 77f1a931fd
6 changed files with 67 additions and 31 deletions

View File

@@ -9,19 +9,22 @@ namespace mstdnCats.Services
{
// Setup DB
IDocumentCollection<Post>? collection = null;
try
if (_dbname != null)
{
// Initialize DB
var store = new DataStore($"{_dbname}.json", minifyJson: false);
collection = store.GetCollection<Post>();
}
catch
{
return Task.FromResult<IDocumentCollection<Post>>(null);
}
try
{
// Initialize DB
var store = new DataStore($"{_dbname}.json", minifyJson: false);
collection = store.GetCollection<Post>();
}
catch
{
return Task.FromResult<IDocumentCollection<Post>>(null);
}
// Return collection
// Return collection
return Task.FromResult(collection);
}
return Task.FromResult(collection);
}
}