adonisjs / env

Framework agnostic environment variables parser and validator
https://docs.adonisjs.com/guides/environment-variables
MIT License
37 stars 10 forks source link

Support for other types like integer #15

Closed dcrystalj closed 4 years ago

dcrystalj commented 4 years ago

Why this feature is required (specific use-cases will be appreciated)?

It would be nice to have simple way of parsing integer from env. For example having env variable COUNT=10 will give you string. Currently this is a bit too much work to parse to int because of need to handle undefined and boolean values to satisfy typescript

Have you tried any other work arounds?

parseInt(Env.get('COUNT', 60) as string) but it is just ignoring undefined which is destroying purpose of typescript

thetutlage commented 4 years ago

I agree, this can be improved. Infact, we have plans to allow you to define validations for environment variables and then have more accurate types vs type casting manually as string.

I will do an RFC on it in the coming week and will share the link here.

thetutlage commented 4 years ago

Here's the RFC https://github.com/adonisjs/rfcs/issues/24

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.