# All files / server-old/src/config schema.js

54.55% Statements 6/11
20% Branches 2/10
100% Functions 1/1
60% Lines 6/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    5827x
    27x
    27x

    27x

    127x

    127x

     const buffer = require('crypto').randomBytes(60);
    const token = buffer.toString('base64').replace(/\//g,'_').replace(/\+/g,'-');
    const path = require('path');

    module.exports = {
      __root: 'port',
      port: {
        default: 3000,
        type: Number
      },
      public: {
        default: 'public',
        type: [String, Boolean],
        file: true,
        clean: (value, option) => {
          Iif (/^win/.test(process.platform) && value === 'C:\\Users\\Public') {
            value = option.arg.public || option.def.default;

            if (!value) return;
            const fullpath = path.isAbsolute(value) ? value : path.join(process.cwd(), value);
            return path.normalize(fullpath);
          }
          return value;
        }
      },
      env: {
        default: 'development',
        enum: ['production', 'test', 'development'],
        arg: false,
        env: 'NODE_ENV'
      },
      engine: {
        default: 'pug',
        type: [String, Object]
      },
      views: {
        default: 'views',
        type: String,
        folder: true
      },
      secret: {
        default: 'secret-' + token,
        type: String,
        arg: false
        // TODO: integrate this
        // if (options.secret === 'your-random-string-here') {
        //   throw new ServerError('/server/options/secret/example');
        // }
        //
        // if (/^secret-/.test(options.secret) && options.verbose) {
        //   console.log(new ServerError('/server/options/secret/generated'));
        // }
      },
      'x-powered-by': {
        default: false
      }
    };