I am using config
module from npm with JS or TS.
let's imagine I have the following default.json
:
{
"database": {
"username": "admin",
"password": "admin"
}
}
then somewhere in my code I write
import config from "config";
// ...
config.get('database.username') //
Thing I would like to have is some kind of hint during coding of what I can get from config
.
I can think of usage of constants like
const CONFIG = {
DATABASE: {
USERNAME: "database.username",
PASSWORD: "database.password"
}
}
// and then
const { DATABASE } = CONFIG;
config.get(DATABASE.USERNAME)
but maybe there is some other way, more automatic than manual as we already have this information in configuration files.
Is there a way to achieve this?