How to use the convict.addParser function in convict

To help you get started, we’ve selected a few convict examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github philhawthorne / ha-dockermon / default_settings.js View on Github external
},
    host: {
      doc: 'Optional. URL to remote docker host',
      format: String,
      default: undefined
    },
    port: {
      doc: 'Optional. Port on remote docker host',
      format: 'port_or_windows_named_pipe',
      default: undefined
    }
  }
});

// Load environment dependent configuration
convict.addParser({ extension: ['yml', 'yaml'], parse: yaml.safeLoad });
var config_dir = process.env.config_dir || "./config";
console.log("Loading settings from " + config_dir);

//Check if the configuration file exists, if it doesn't then skip this
try{
  if (fs.existsSync(config_dir + '/configuration.yaml')) {
    config.loadFile(config_dir + '/configuration.yaml');
  }
} catch(err) {
  console.warn("No configuration file detected. Using default settings");
}

// Perform validation
config.validate({allowed: 'warn'});

module.exports = config;
github ThauEx / ffrk-proxy / lib / config.js View on Github external
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const convict = require('convict');
convict.addParser({extension: ['yml', 'yaml'], parse: yaml.safeLoad});

const config = convict({
  application: {
    config: {
      doc: 'name of the config to load',
      format: function check(val) {
        if (!/^.+$/.test(val)) {
          throw new Error('must be a string or number');
        }
      },
      default: 'default',
      env: 'CONFIG',
      arg: 'config',
    },
    debug: {
      doc: 'enable debug',
github telstra / openapi-platform / packages / config / src / schema.ts View on Github external
import convict from 'convict';
import yaml from 'js-yaml';
import json5 from 'json5';
convict.addParser([
  { extension: 'json', parse: JSON.parse },
  { extension: ['yaml', 'yml'], parse: yaml.safeLoad },
  { extension: ['json5'], parse: json5.parse },
]);

function logLevel(options) {
  return {
    doc: 'The level of logging to be recorded',
    format: ['error', 'info', 'verbose', 'debug', 'silly'],
    ...options,
  };
}

function logPath(options) {
  return {
    doc: 'Where the logs will be recorded to',

convict

Featureful configuration management library for Node.js (nested structure, schema validation, etc.)

Apache-2.0
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis