setup: clean up

This commit is contained in:
wukko 2024-03-05 23:51:25 +06:00
parent efe2e6a437
commit b890d89c7d

View file

@ -39,27 +39,27 @@ function setup() {
console.log(Bright("\nCool! What's the domain this API instance will be running on? (localhost)\nExample: co.wuk.sh")); console.log(Bright("\nCool! What's the domain this API instance will be running on? (localhost)\nExample: co.wuk.sh"));
rl.question(q, apiURL => { rl.question(q, apiURL => {
ob['API_URL'] = `http://localhost:9000/`; ob.API_URL = `http://localhost:9000/`;
ob['API_PORT'] = 9000; ob.API_PORT = 9000;
if (apiURL && apiURL !== "localhost") ob['API_URL'] = `https://${apiURL.toLowerCase()}/`; if (apiURL && apiURL !== "localhost") ob.API_URL = `https://${apiURL.toLowerCase()}/`;
console.log(Bright("\nGreat! Now, what port will it be running on? (9000)")); console.log(Bright("\nGreat! Now, what port will it be running on? (9000)"));
rl.question(q, apiPort => { rl.question(q, apiPort => {
if (apiPort) ob['API_PORT'] = apiPort; if (apiPort) ob.API_PORT = apiPort;
if (apiPort && (apiURL === "localhost" || !apiURL)) ob['API_URL'] = `http://localhost:${apiPort}/`; if (apiPort && (apiURL === "localhost" || !apiURL)) ob.API_URL = `http://localhost:${apiPort}/`;
console.log(Bright("\nWhat will your instance's name be? Usually it's something like eu-nl aka region-country. (local)")); console.log(Bright("\nWhat will your instance's name be? Usually it's something like eu-nl aka region-country. (local)"));
rl.question(q, apiName => { rl.question(q, apiName => {
ob['API_NAME'] = apiName.toLowerCase(); ob.API_NAME = apiName.toLowerCase();
if (!apiName || apiName === "local") ob['API_NAME'] = "local"; if (!apiName || apiName === "local") ob.API_NAME = "local";
console.log(Bright("\nOne last thing: would you like to enable CORS? It allows other websites and extensions to use your instance's API.\ny/n (n)")); console.log(Bright("\nOne last thing: would you like to enable CORS? It allows other websites and extensions to use your instance's API.\ny/n (n)"));
rl.question(q, apiCors => { rl.question(q, apiCors => {
let answCors = apiCors.toLowerCase().trim(); let answCors = apiCors.toLowerCase().trim();
if (answCors !== "y" && answCors !== "yes") ob['CORS_WILDCARD'] = '0' if (answCors !== "y" && answCors !== "yes") ob.CORS_WILDCARD = '0'
final() final()
}) })
}) })
@ -71,25 +71,25 @@ function setup() {
console.log(Bright("\nAwesome! What's the domain this web app instance will be running on? (localhost)\nExample: cobalt.tools")); console.log(Bright("\nAwesome! What's the domain this web app instance will be running on? (localhost)\nExample: cobalt.tools"));
rl.question(q, webURL => { rl.question(q, webURL => {
ob['WEB_URL'] = `http://localhost:9001/`; ob.WEB_URL = `http://localhost:9001/`;
ob['WEB_PORT'] = 9001; ob.WEB_PORT = 9001;
if (webURL && webURL !== "localhost") ob['WEB_URL'] = `https://${webURL.toLowerCase()}/`; if (webURL && webURL !== "localhost") ob.WEB_URL = `https://${webURL.toLowerCase()}/`;
console.log( console.log(
Bright("\nGreat! Now, what port will it be running on? (9001)") Bright("\nGreat! Now, what port will it be running on? (9001)")
) )
rl.question(q, webPort => { rl.question(q, webPort => {
if (webPort) ob['WEB_PORT'] = webPort; if (webPort) ob.WEB_PORT = webPort;
if (webPort && (webURL === "localhost" || !webURL)) ob['WEB_URL'] = `http://localhost:${webPort}/`; if (webPort && (webURL === "localhost" || !webURL)) ob.WEB_URL = `http://localhost:${webPort}/`;
console.log( console.log(
Bright("\nOne last thing: what default API domain should be used? (co.wuk.sh)\nIf it's hosted locally, make sure to include the port:") + Cyan(" localhost:9000") Bright("\nOne last thing: what default API domain should be used? (co.wuk.sh)\nIf it's hosted locally, make sure to include the port:") + Cyan(" localhost:9000")
); );
rl.question(q, apiURL => { rl.question(q, apiURL => {
ob['API_URL'] = `https://${apiURL.toLowerCase()}/`; ob.API_URL = `https://${apiURL.toLowerCase()}/`;
if (apiURL.includes(':')) ob['API_URL'] = `http://${apiURL.toLowerCase()}/`; if (apiURL.includes(':')) ob.API_URL = `http://${apiURL.toLowerCase()}/`;
if (!apiURL) ob['API_URL'] = "https://co.wuk.sh/"; if (!apiURL) ob.API_URL = "https://co.wuk.sh/";
final() final()
}) })
}); });