Refactor and doc

This commit is contained in:
ycc
2024-09-04 10:53:12 +02:00
parent fba1608edb
commit bb36ac0fb4
9 changed files with 161 additions and 45 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"cloud.o-forge.io/core/oc-lib/config"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
)
@@ -51,11 +52,11 @@ type API struct{}
// GetState returns the state of the API
func (a *API) GetState() (State, int, error) {
// Check if the database is up
err := mongo.MONGOService.TestDB(GetConfig())
err := mongo.MONGOService.TestDB(config.GetConfig())
if err != nil {
return DB_FALLOUT, 200, err // If the database is not up, return database fallout
}
err = mongo.MONGOService.TestCollections(GetConfig(), []string{}) // Check if the collections are up
err = mongo.MONGOService.TestCollections(config.GetConfig(), []string{}) // Check if the collections are up
if err != nil {
return UNPROCESSABLE_ENTITY, 200, err // If the collections are not up, return unprocessable entity
}