mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
added minLength to env variables
This commit is contained in:
parent
e650454508
commit
8cbbbb8cc1
2 changed files with 12 additions and 7 deletions
|
@ -13,23 +13,27 @@
|
|||
"name": "DB_USER",
|
||||
"generated": false,
|
||||
"default": "postgres",
|
||||
"hide": false
|
||||
"hide": false,
|
||||
"minLength": 4
|
||||
},
|
||||
{
|
||||
"name": "DB_PASSWORD",
|
||||
"generated": false,
|
||||
"hide": true
|
||||
"hide": true,
|
||||
"minLength": 8
|
||||
},
|
||||
{
|
||||
"name": "MINIO_USER",
|
||||
"generated": false,
|
||||
"default": "minIO",
|
||||
"hide": false
|
||||
"hide": false,
|
||||
"minLength": 4
|
||||
},
|
||||
{
|
||||
"name": "MINIO_PASSWORD",
|
||||
"generated": false,
|
||||
"hide": true
|
||||
"hide": true,
|
||||
"minLength":8
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ type env_config = {
|
|||
input?: string;
|
||||
default?: string;
|
||||
hide?: boolean;
|
||||
minLength: number;
|
||||
};
|
||||
type json_config = {
|
||||
commands: string[];
|
||||
|
@ -29,7 +30,7 @@ let missingConfigs: env_config[] = [];
|
|||
if (fs.existsSync(".env")) {
|
||||
dotenv.config();
|
||||
for (const setting of config.requiredKeys) {
|
||||
if (!process.env[setting.name]) {
|
||||
if (!process.env[setting.name] || process.env[setting.name]!.length <= setting.minLength) {
|
||||
missingConfigs.push(setting);
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +49,10 @@ if (fs.existsSync(".env")) {
|
|||
let input: string = "";
|
||||
do {
|
||||
input = readlineSync.question(
|
||||
`Enter the ${setting.name} ${setting.default ? `(${setting.default})` : ""}: `,
|
||||
`Enter the ${setting.name} ${setting.default ? `(${setting.default})` : "" + ` min: ${setting.minLength}`}: `,
|
||||
{ defaultInput: setting.default, hideEchoBack: setting.hide }
|
||||
);
|
||||
} while (!input);
|
||||
} while (!input && input.length <= setting.minLength);
|
||||
process.env[setting.name] = input;
|
||||
} else if (setting.name === "TOKEN_SECRET") {
|
||||
// generating a random JWT secret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue