-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.js
More file actions
47 lines (42 loc) · 758 Bytes
/
Copy pathsetup.js
File metadata and controls
47 lines (42 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const crypto = require("crypto");
const fs = require("fs");
const CONFIG_PATH = "./config.json";
const CRYPTO_BYTES = 32;
const SALT_SIZE = 12;
const config =
{
database:
{
host: "",
user: "",
password: "",
dbName: "",
port: 3306,
charset: "utf8mb4"
},
redis:
{
host: "localhost",
port: 6379
},
security:
{
sessionSecret: crypto.randomBytes(CRYPTO_BYTES).toString("hex"),
saltSize: SALT_SIZE
}
};
if (fs.existsSync(CONFIG_PATH))
{
console.log(`Config file already exists! Please remove ${CONFIG_PATH} and run the setup script again.`);
} else
{
try
{
let jsonString = JSON.stringify(config, null, 4);
fs.writeFileSync(CONFIG_PATH, jsonString, "utf8");
console.log("Setup complete!");
} catch (e)
{
throw e;
}
}