Skip to content

Conversation

@tigattack
Copy link
Contributor

Checks DB connection & lock status.

I'm largely unfamiliar with TS (and Mongo for that matter lol), but this change has achieved my goal and seems to function well. Hopefully it's suitable. Let me know what you think.

Responses

Connected and unlocked:

{
    "status": "ok",
    "db_health": {
        "status": "UP",
        "details": {
            "version": "6.0.19",
            "uptime": 6843,
            "writable": true
        }
    }
}

Connected and locked:

{
    "status": "warning",
    "db_health": {
        "status": "READONLY",
        "details": {
            "version": "6.0.19",
            "uptime": 7244,
            "writable": false
        },
        "message": "Database is read-only (fsyncLock enabled)"
    }
}

Disconnected:

{
    "status": "error",
    "db_health": {
        "status": "DOWN",
        "message": "Error querying database health"
    }
}

@tigattack
Copy link
Contributor Author

On second thoughts, perhaps READONLY should be WARNING... Open to thoughts.

@Yooooomi
Copy link
Owner

Hello, nice idea!

I feel like this could benefit a little authentication. Can you tell me what's possible for you in your context for authentication? Maybe http basic auth could do the work

@tigattack
Copy link
Contributor Author

tigattack commented Mar 22, 2025

I'm not convinced authentication should be necessary for this, but I'm by no means against it, and it wouldn't be breaking for my use case (Docker healthcheck, just runs an arbitrary command and looks at the return code to determine success/failure).

That said, it's probably not something I'd be prepared to implement personally given my current level of knowledge with both TypeScript and your_spotify...

Perhaps, as a middle-ground solution, the MongoDB version could be removed from the response? I feel this would alleviate any potential concerns with the endpoint being unauthenticated.

@tigattack
Copy link
Contributor Author

@Yooooomi please let me know if you're interested in going ahead with this, or have any further thoughts. I'd love to see the feature added but will close the PR if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants