TaitoUnited / full-stack-template

Template for cloud-native applications and microservices running as containers/functions on Kubernetes, Docker Compose, or cloud. You can choose the stack during project creation.
https://taitounited.github.io/taito-cli/templates
MIT License
36 stars 8 forks source link

Feat/openapi docs #137

Closed taavettik closed 1 year ago

taavettik commented 1 year ago

Replace the custom made api documentation generation method with OpenAPI-compatible schema generation from router JOI types

keskiju commented 1 year ago

Looks good 👍

On rest.ts we have:

if (config.COMMON_ENV !== 'prod') {
  restMiddlewares.push(apiDocRouter.middleware());
}

And on graphql.ts we have:

  introspection: ['local', 'dev', 'test'].includes(config.COMMON_ENV || ''),
  playground: ['local', 'dev', 'test'].includes(config.COMMON_ENV || '')

We should unify these. [ 'local' ] would be a safe default as this way you don't make docs/introspection and playground public by accident. You need to intentionally enable them for each environment instead. Maybe we should have environment variables API_DOCS_ENABLED: true and API_PLAYGROUND_ENABLED: true; enabled on docker-compose.yaml by default, and on helm-dev.yaml like this:

full-stack:
  services:
    server:
      env:
        # Enable if API docs and playground required on dev.
        # API_DOCS_ENABLED: true
        # API_PLAYGROUND_ENABLED: true
taavettik commented 1 year ago

Maybe we should have environment variables API_DOCS_ENABLED: true and API_PLAYGROUND_ENABLED: true; enabled on docker-compose.yaml by default, and on helm-dev.yaml like this:

I'd say that sounds wise. Will do