node icon indicating copy to clipboard operation
node copied to clipboard

`base.yml` is ignored when the config files is encrypted and then it's unencrypted at runtime

Open leosuncin opened this issue 1 year ago • 0 comments

With the following files::

config/base.yml

logger: true

server:
  host: 0.0.0.0
  port: 4200

config/production.yml


jwt:
  jwtSecret: ENC[AES256_GCM,data:TTQroa9FcjVxIDp+49lbGZTiez6iy1QQf2KtUNCsyVcIg63nQN7dQujhzk5hR1CyGHjzCpzaWyeVoV46/mAi4g==,iv:mgYTGnpJTro0nyvaVP7gHPvga6/6F1ZZp9NdExrHTJc=,tag:gW5fLHwrScAzhtiTB84CJQ==,type:str]

sops: # SOPS encryption...

config/schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["logger", "server", "jwt"],
  "additionalProperties": false,
  "properties": {
    "logger": {
      "type": "boolean"
    },
    "server": {
      "type": "object",
      "additionalProperties": false,
      "required": ["host", "port"],
      "properties": {
        "host": {
          "type": "string"
        },
        "port": {
          "type": "integer"
        }
      }
    },
    "jwt": {
      "type": "object",
      "required": ["jwtSecret"],
      "additionalProperties": false,
      "properties": {
        "jwtSecret": {
            "type": "string",
            "minLength": 32
        }
      }
    }
  }
}

src/config.ts

import StrongConfig from '@strong-config/node';

import type { Config } from '../config/config.d.ts';

const strongConfig = new StrongConfig();

const config = strongConfig.getConfig() as unknown as Config;

export default config;

When run without decrypt the configuration it fails due to not passing the validation thanks to schema.json, I assume is not reading base.yml, because it works when the configuration file is decrypted before run the app.

System information

@strong-config/node 1.3.1 node.js version: 22.7.0 OS: Ubuntu 20.04 WSL

leosuncin avatar Sep 19 '24 19:09 leosuncin