vuestorefront/vue-storefront

Implementing health check in the core module

Closed this issue · 3 comments

Acceptance criteria:
Health check is available to be used in newly generated project for the customer.

➤ Patrick Andrew commented:

The goal here is to add an api endpoint /healthz that will return just ok text. It will be completely enough for cluster to manage application.

The server middleware is pretty simple:

export default function (req, res, next) {
res.end("ok")
}Now we have to work on how it can be added automatically from our modules.

We can use our nuxt-module here (which is the best solution here as all of our customers have it), but since it’s buildModule we can just use this.addServerMiddleware, but it’s feasible to do it via plugin: https://github.com/vuestorefront/vue-storefront/blob/main/packages/core/middleware/nuxt/index.js ( https://github.com/vuestorefront/vue-storefront/blob/main/packages/core/middleware/nuxt/index.js|smart-link ) quite hacky but will work

Another solution is to add this middleware from our middleware module - this one is a regular module so you can use this.addServerMiddleware right away. However, middleware sometimes can be run a separate app… it can cause an issues here…

➤ Patrick Andrew commented:

Recap:

  1. write server middleware file that returns ok response in the nuxt-module package in the core
  2. create plugin that applies this middleware, reference: nuxt/nuxt#3934 ( https://github.com/nuxt/nuxt.js/issues/3934|smart-link )
  3. add this plugin from nuxt-module package
  4. test both in prod and dev mode