denox
denox copied to clipboard
Would be amazing if this could configure enviroment variables as well
Issue Type
- [ ] Bug Report
- [x] Feature Request
- [ ] Other
Possible Solutions
scripts:
# "denox run start" will execute main.ts with example.com networking permissions
start:
file: main.ts
env:
PORT: 80
DOMAIN: "example.net"
deno_options:
allow-net: example.com
# "denox run develop" will execute main.ts with localhost networking permissions and source code cache reloaded
develop:
file: main.ts
env:
PORT: 3000
DOMAIN: "localhost"
deno_options:
allow-net: localhost
reload: true
Then it would add the variables to Deno using Deno.env.set('NAME', 'VALUE') Then we can access it via Deno.env.get("NAME")
It would require --allow-env
to be set.
Thank you @khrome83 for the suggestion, I will soon add support for configuring env variables as well as loading them from .env
file
Yeah, I was thinking about this last night. Being able to specify loading from .env
or better .env.dev
, .env.stage
, .env.prod
would be ideal as well.
There are 3-4 third party mods that take care of .env files, but they either always assume .env
or they require you specify the file to load in code, which defeats the purpose.
Agreed specifying it in code does defeat the purpose.
I'm wondering what naming would be better for loading env file and specifying env variables in deno-workspace
scripts:
start:
file: main.ts
env_file: ./.env
env:
PORT: 80
DOMAIN: "example.net"
OR
scripts:
start:
file: main.ts
env: ./.env
env_vars:
PORT: 80
DOMAIN: "example.net"
OR
I think this may be best as to clearly define what the value should be
scripts:
start:
file: main.ts
env_file: ./.env
env_vars:
PORT: 80
DOMAIN: "example.net"
I am fine with the last one.
I can also see something like this -
scripts:
start:
file: main.ts
env:
file: ./.env
vars:
PORT: 80
DOMAIN: "example.net"
I think this should also allow the global layer, like you do with permissions.
Optionally, would you use a file and the vars at the same time? In other words if the YAML parsed as a string vs a object, you could handle it different.
Parse as a object, no need for a file
scripts:
start:
file: main.ts
env:
PORT: 80
DOMAIN: "example.net"
Parses as a string, going to disk
scripts:
start:
file: main.ts
env: ./.env
Which module will you be using for the environment variable file read? I'm assuming dotenv?
Yeah, that was my thought.
Zane Milakovic On Jun 15, 2020, 10:56 AM -0500, Ryan [email protected], wrote:
Which module will you be using for the environment variable file read? I'm assuming dotenv? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Yeah, that was my thought. … --- Zane Milakovic On Jun 15, 2020, 10:56 AM -0500, Ryan @.***>, wrote: Which module will you be using for the environment variable file read? I'm assuming dotenv? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
It was always the defacto package I would turn to. I'd like to see support for inline scripts in denox and env variable support would be an important component.