mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-07 06:08:54 +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",
|
"name": "DB_USER",
|
||||||
"generated": false,
|
"generated": false,
|
||||||
"default": "postgres",
|
"default": "postgres",
|
||||||
"hide": false
|
"hide": false,
|
||||||
|
"minLength": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "DB_PASSWORD",
|
"name": "DB_PASSWORD",
|
||||||
"generated": false,
|
"generated": false,
|
||||||
"hide": true
|
"hide": true,
|
||||||
|
"minLength": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "MINIO_USER",
|
"name": "MINIO_USER",
|
||||||
"generated": false,
|
"generated": false,
|
||||||
"default": "minIO",
|
"default": "minIO",
|
||||||
"hide": false
|
"hide": false,
|
||||||
|
"minLength": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "MINIO_PASSWORD",
|
"name": "MINIO_PASSWORD",
|
||||||
"generated": false,
|
"generated": false,
|
||||||
"hide": true
|
"hide": true,
|
||||||
|
"minLength":8
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ type env_config = {
|
||||||
input?: string;
|
input?: string;
|
||||||
default?: string;
|
default?: string;
|
||||||
hide?: boolean;
|
hide?: boolean;
|
||||||
|
minLength: number;
|
||||||
};
|
};
|
||||||
type json_config = {
|
type json_config = {
|
||||||
commands: string[];
|
commands: string[];
|
||||||
|
@ -29,7 +30,7 @@ let missingConfigs: env_config[] = [];
|
||||||
if (fs.existsSync(".env")) {
|
if (fs.existsSync(".env")) {
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
for (const setting of config.requiredKeys) {
|
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);
|
missingConfigs.push(setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +49,10 @@ if (fs.existsSync(".env")) {
|
||||||
let input: string = "";
|
let input: string = "";
|
||||||
do {
|
do {
|
||||||
input = readlineSync.question(
|
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 }
|
{ defaultInput: setting.default, hideEchoBack: setting.hide }
|
||||||
);
|
);
|
||||||
} while (!input);
|
} while (!input && input.length <= setting.minLength);
|
||||||
process.env[setting.name] = input;
|
process.env[setting.name] = input;
|
||||||
} else if (setting.name === "TOKEN_SECRET") {
|
} else if (setting.name === "TOKEN_SECRET") {
|
||||||
// generating a random JWT secret
|
// generating a random JWT secret
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue