Healthcheck endpoint?

default discord avatar
Derosul
3 weeks ago
6

I'm currently running my payload instance dockerized and I want the container supervisor to check up on the health of the instance, is there any health endpoint on the Payload API?

  • default discord avatar
    noheadphones
    3 weeks ago

    Definitely not as far as I know, though seems like a useful feature to have



    Could probably roll out your own custom endpoint pretty easily though

  • discord user avatar
    denolfe
    Payload Team
    3 weeks ago

    Nothing built-in currently. But, like Paul said, this would be very simple to do with a custom endpoint.



    Here is a simple example. Adding this to your payload config will make a health check endpoint on

    /api/health

    endpoints: [
        {
          path: '/health',
          method: 'get',
          handler: (req, res) => {
            res.status(200).send('OK')
          },
        },
      ],


    Docs:

    https://payloadcms.com/docs/rest-api/overview#custom-endpoints


    You could use

    req.payload

    to do some more comprehensive health checks within that function if desired



    overrideAccess: true

    will likely come in handy in your

    req.payload.find

    calls or similar.

  • default discord avatar
    Derosul
    3 weeks ago

    Cool! Thanks for the clarification!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.