guide config - wwwsolutions/nestjs-starter-kit GitHub Wiki

Guide - Configs

api-config-app

This is a configuration library powered by @nestjs/config and Joi. It loads environment variables from .env.* files and uses validation.schema for validation which is also used to set default values. Finally, it exposes ApiConfigAppModule and different configurations which can be consumed in different ways by the application.

This library is required and encapsulates configurations for core application functionality.

Structure

Usage

  • environment variables:

    • add/edit environment variables in .env.* files.
  • validation and defaults:

    • add/edit validation rules for environment variables in validation.schema.ts file.
  • application configuration registration:

    • add/edit application configuration set in app-configs.registration.ts file.

api-config-features

This is a configuration library powered by @nestjs/config and Joi. It loads environment variables from .env.* files and uses validation.schema for validation which is also used to set default values. Finally, it exposes ApiConfigFeaturesModule and different configurations which can be consumed in different ways by the application.

Configurations in this library are optional.

Structure

Usage

  • environment variables:

    • add/edit environment variables in .env.* files.
  • validation and defaults:

    • add/edit validation rules for environment variables in validation.schema.ts file.
  • API integration configuration registration:

    • add/change API integration configuration set in api-integration-configs.registration.ts file.
  • business logic (features) configuration registration:

    • add feature configuration in business-logic-configs.registration.ts file.

api-config-docker

STATUS: unfinished

This is a custom virtualization library powered by Nx commands and docker-compose. The purpose of the library is to serve as a container for docker-compose config fragments which can be combined and executed to build a final docker-compose files in different contexts. It exposes no modules and no configurations.

Structure

Workflow

Generate docker-compose file and execute

It generates .docker/generated/docker-compose-stack.development.yaml file and execute it by building images and starting containers in detached mode for corresponding context.

  • run command sequence:
    • nx run api-config-docker:compose --mode=development
    • nx run api-config-docker:up --mode=development

Stop containers and clean up

It stops containers and removes volumes and then cleans up by removing .docker/generated/docker-compose-stack.development.yaml file for corresponding context.

  • run command sequence:
    • nx run api-config-docker:down --mode=development
    • nx run api-config-docker:clean --mode=development

Motivation

Why did I organized it in this manner?

  • modularization - to isolate all virtualization script in one place.
  • practicality - good riddance to npm script clutter
  • flexibility - comes with utilization of Nx commands

⚠️ **GitHub.com Fallback** ⚠️