All files / src/config errors.js

85% Statements 17/20
0% Branches 0/2
62.5% Functions 5/8
100% Lines 13/13
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 58 59 60 61 62 63 64 65 66 671x 7x           1x           1x           1x         1x                 1x         2x         1x         2x         1x           1x           1x  
const error = require('../../error').defaults({
  url: ({ code }) => `https://serverjs.io/documentation/errors/#${
    code.toLowerCase().replace(/[^\w]+/g, '-')
  }`,
  status: 500
});
 
error['/server/options/notobject'] = `
  Your options must be an object as required by the options definition.
  If you are a developer and want to accept a single option, make sure
  to use the '__root' property.
`;
 
error['/server/options/noarg'] = ({ key }) => `
  The option '${key}' cannot be passed through the arguments of server. This
  might be because it's sensitive and it has to be set in the environment.
  Please read the documentation for '${key}' and make sure to set it correctly.
`;
 
error['/server/options/noenv'] = ({ key }) => `
  The option '${key}' cannot be passed through the environment of server.
  Please read the documentation for '${key}' and make sure to set it correctly.
`;
 
error['/server/options/cannotextend'] = ({ type, key }) => `
  The option "${key}" must be an object but it received "${type}".
  Please check your options to make sure you are passing an object.
${type === 'undefined' ? `
  If you are the creator of the plugin and you are receiving 'undefined', you
  could allow for the default behaviour to be an empty object 'default: {}'
` : ''}
`;
 
error['/server/options/required'] = ({ key }) => `
  The option '${key}' is required but it was not set neither as an argument nor
  in the environment. Please make sure to set it.
`;
 
error['/server/options/type'] = ({ key, expected, received, value }) => `
  The option '${key}' should be a '[${expected}]' but you passed a '${received}':
  ${JSON.stringify(value)}
`;
 
error['/server/options/enum'] = ({ key, value, possible }) => `
  The option '${key}' has a value of '${value}' but it should have one of these values:
  ${JSON.stringify(possible)}
`;
 
error['/server/options/validate'] = ({ key, value }) => `
  Failed to validate the option '${key}' with the value '${value}'. Please
  consult this option documentation for more information.
`;
 
error['/server/options/secret/example'] = `
  It looks like you are trying to use 'your-random-string-here' as the secret,
  just as in the documentation. Please don't do this! Create a strong secret
  and store it in your '.env'.
`;
 
error['/server/options/secret/generated'] = `
  Please change the secret in your environment configuration.
  The default one is not recommended and should be changed.
  More info in https://serverjs.io/errors#defaultSecret
`;
 
module.exports = error;