Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can
also pass a custom transformer function (see TransformerFunc) as well a validator function or array of
validator functions. (Import the Validators
library from
this library to explore the bundled validators or write your own by implementing ValidatorFunc.)
The most common usage of this will be the following (see more examples below for advanced usage in context):
// Get a possibly-undefined string from the SOME_VAR environment variable
configValue('SOME_VAR');
// Get a string with a default value of 'some default' from the SOME_VAR environment variable
configValue('SOME_VAR', 'some default');
// Get a possibly-undefined number from the SOME_VAR environment variable
configValue('SOME_VAR', 'num');
// Get a number with a default value of 5 from SOME_VAR
configValue('SOME_VAR', 'num', 5);
// Get a required string from SOME_VAR with no default (note: `REQUIRED` is a special imported symbol from this
// library)
configValue('SOME_VAR', REQUIRED);
// Get a required number from SOME_VAR with no default
configValue('SOME_VAR', 'num', REQUIRED);
Following is a more real-world example of how this might all be used in context
const configDef = {
port: configValue('PORT', 'num', 3000),
hiPort: configValue('PORT', 'num', 30_000, hiport),
host: configValue('HOST', 'str', 'http://localhost', hostValidator),
db: {
url: configValue('DB_URL', 'str', 'postgres://postgres@localhost:5432'),
migrateOnStart: configValue('DB_MIGRATE_ON_START', 'bool', false),
},
signatureSecret: configValue('SIGNATURE_SECRET', 'str', [required, exactLength(32), hex]),
secondsToWaitForThing: configValue('SECONDS_TO_WAIT_FOR_THING', 'num', required),
}
export const config = validate(configDef);
NOTE: This function uses any-casts. This is because the underlying transformer functions are overloaded and require either one argument configuration or the other, which gets messy in a function like this. Since this function is itself properly overloaded, it's safe to use any-casts to solve this here.
Generated using TypeDoc
Get a value with the given specification. The standard transformers available are 'str', 'num' and 'bool'. You can also pass a custom transformer function (see TransformerFunc) as well a validator function or array of validator functions. (Import the
Validators
library from this library to explore the bundled validators or write your own by implementing ValidatorFunc.)The most common usage of this will be the following (see more examples below for advanced usage in context):