Healthcheck endpoint?

default discord avatar
derosullast year
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
    noheadphoneslast year

    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
    last year

    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
    derosullast year

    Cool! Thanks for the clarification!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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