Search…
Env
Statically defined environment variables enable a script to define configuration that's accessible from scrip.env based on weights and environment. env vars appear as properties of script.env.
Values can be any static literal, including object and arrays.
Note: env variables cannot override any built-in script.env variables such as version, url, etc.

@env(options)

Arguments
  • options { Object } Optional options object.
    • name { String } Optional name to override declared member name.
    • environment { String = "*" } production, development, *
    • weight { Number = 0 }
    • active { Boolean = true } Enable or disable entirely.

Examples

1
const { env } = require('decorators')
2
3
class EnvVars {
4
5
@env({name: 'myEnv__foo', environment: 'development' })
6
static devFoo = 'dev bar'
7
8
@env({name: 'myEnv__foo', environment: 'production' })
9
static prodFoo = 'prod bar'
10
11
@env
12
static myobj = {
13
foo: 'bar',
14
arr: [1, 2, 3]
15
}
16
17
}
18
19
// --------------
20
21
return script.env
22
23
// {
24
// "myEnv__foo": "dev bar",
25
// "myobj": {
26
// "arr": [
27
// 1,
28
// 2,
29
// 3
30
// ],
31
// "foo": "bar"
32
// },
33
// "name": "development",
34
// // ...
35
// }
Copied!
Last modified 2mo ago
Copy link