Skip to main content

QEnvironment

@quik/core


@quik/core / QEnvironment

Class: QEnvironment

Defined in: configuration/QEnvironment.ts:16

Class used to interact with the environment variables. Use the object exported by this module to get various environment variable values.

Constructors

Constructor

new QEnvironment(): QEnvironment

Returns

QEnvironment

Accessors

keys

Get Signature

get keys(): string[]

Defined in: configuration/QEnvironment.ts:20

Returns the list of exposed ENV variables.

Returns

string[]

Methods

array()

array(field, separator?, defaultValue?): string[]

Defined in: configuration/QEnvironment.ts:80

Returns the array value of a given environment variable.

Parameters

field

string

The name of the environmental variable.

separator?

string = ","

The separator used to split an array defined as a string.

defaultValue?

string = ""

The default value if the variable doesn't exist.

Returns

string[]


boolean()

boolean(field): boolean

Defined in: configuration/QEnvironment.ts:68

Returns the boolean value of a given environment variable.

Parameters

field

string

The name of the flag.

Returns

boolean


flag()

flag(flagName): boolean

Defined in: configuration/QEnvironment.ts:101

An alias for the getEnv().bool method.

Parameters

flagName

string

The name of the flag.

Returns

boolean


get()

get(field, defaultValue?): string

Defined in: configuration/QEnvironment.ts:39

Returns the value of a given environment variable.

Parameters

field

string

The name of the environmental variable.

defaultValue?

any = null

The default value if the variable doesn't exist.

Returns

string


int()

int(field, defaultValue?): number

Defined in: configuration/QEnvironment.ts:49

Returns the integer value of a given environment variable.

Parameters

field

string

The name of the environmental variable.

defaultValue?

number = 0

The default value if the variable doesn't exist.

Returns

number


number()

number(field, defaultValue?): number

Defined in: configuration/QEnvironment.ts:59

Returns the number value of a given environment variable.

Parameters

field

string

The name of the environmental variable.

defaultValue?

number = 0

The default value if the variable doesn't exist.

Returns

number


reload()

reload(file?): void

Defined in: configuration/QEnvironment.ts:29

Reload the environment variables from the given file.

Parameters

file?

string = ".env"

The file containing the environment variables.

Returns

void


string()

string(field, defaultValue?): string

Defined in: configuration/QEnvironment.ts:92

An alias for the getEnv().get method.

Parameters

field

string

The name of the environmental variable.

defaultValue?

string = ""

The default value if the variable doesn't exist.

Returns

string


url()

url(field, defaultValue?): string

Defined in: configuration/QEnvironment.ts:111

Returns a valid URL value of a given environment variable.

Parameters

field

string

The name of the flag.

defaultValue?

string = ""

The default value if the variable doesn't exist.

Returns

string