Skip to content

Commit c3897a7

Browse files
committed
feat: configuration updates for domain deployment
1 parent b30fe32 commit c3897a7

4 files changed

Lines changed: 95 additions & 88 deletions

File tree

src/backend/auth/github.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ async function authenticateAndCreateJWT(
6565

6666
const body = await resp.json();
6767

68+
if (!body.access_token) {
69+
console.error("OAuth token exchange failed:", body);
70+
ctx.response.headers.set("Access-Control-Allow-Origin", "*");
71+
ctx.response.body = "not authorized";
72+
return;
73+
}
74+
6875
const { status, userId } = await checkUser(body.access_token, provider);
6976

7077
ctx.response.headers.set("Access-Control-Allow-Origin", "*");
7178

72-
if (status.matchedCount == 1) {
79+
if (status.matchedCount == 1 || status.upsertedId !== undefined) {
7380
const id_jwt = await createJWT(provider, userId);
7481
Sentry.captureMessage("User " + userId + " logged in", "info");
7582
ctx.response.body = id_jwt;

src/backend/shell_scripts/automate.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ if [ "$arg1" = "-u" ]; then
3232
}
3333
charset utf-8;
3434
client_max_body_size 20M;
35-
ssl_certificate /etc/letsencrypt/live/domains.mdgspace.org-0002/fullchain.pem;
36-
ssl_certificate_key /etc/letsencrypt/live/domains.mdgspace.org-0002/privkey.pem;
35+
ssl_certificate /etc/letsencrypt/live/domains.pluto.mdgspace.org/fullchain.pem;
36+
ssl_certificate_key /etc/letsencrypt/live/domains.pluto.mdgspace.org/privkey.pem;
3737
include /etc/letsencrypt/options-ssl-nginx.conf;
3838
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
3939
}" > /etc/nginx/sites-available/$arg3.conf;
@@ -62,8 +62,8 @@ elif [ "$arg1" = "-p" ]; then
6262
}
6363
charset utf-8;
6464
client_max_body_size 20M;
65-
ssl_certificate /etc/letsencrypt/live/domains.mdgspace.org-0002/fullchain.pem;
66-
ssl_certificate_key /etc/letsencrypt/live/domains.mdgspace.org-0002/privkey.pem;
65+
ssl_certificate /etc/letsencrypt/live/domains.pluto.mdgspace.org/fullchain.pem;
66+
ssl_certificate_key /etc/letsencrypt/live/domains.pluto.mdgspace.org/privkey.pem;
6767
include /etc/letsencrypt/options-ssl-nginx.conf;
6868
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
6969
}" > /etc/nginx/sites-available/$arg3.conf;

src/backend/shell_scripts/container.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ sudo echo "# Virtual Host configuration for $2
5555
}
5656
charset utf-8;
5757
client_max_body_size 20M;
58-
ssl_certificate /etc/letsencrypt/live/domains.mdgspace.org-0002/fullchain.pem;
59-
ssl_certificate_key /etc/letsencrypt/live/domains.mdgspace.org-0002/privkey.pem;
58+
ssl_certificate /etc/letsencrypt/live/domains.pluto.mdgspace.org/fullchain.pem;
59+
ssl_certificate_key /etc/letsencrypt/live/domains.pluto.mdgspace.org/privkey.pem;
6060
include /etc/letsencrypt/options-ssl-nginx.conf;
6161
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
6262
}" > /etc/nginx/sites-available/$2.conf

src/cli/features/createDomain.ts

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,92 @@ import chalk from 'chalk'
33
import inquirer from 'inquirer'
44
import { promptUser } from '../utils/promptTaker.js';
55

6-
let domain = 'domains.mdgspace.org';
6+
let domain = 'domains.pluto.mdgspace.org';
77

88
async function selectResourceType() {
9-
const { resourceType } = await inquirer.prompt([
10-
{
11-
type: 'list',
12-
name: 'resourceType',
13-
message: 'Select the resource type:',
14-
choices: ['URL', 'PORT', 'GITHUB'],
15-
},
16-
]);
17-
return resourceType;
18-
}
19-
async function selectDockerPresent() {
20-
const { resourceType } = await inquirer.prompt([
21-
{
22-
type: 'list',
23-
name: 'resourceType',
24-
message: 'Is Dockerfile present?',
25-
choices: ['No', 'Yes'],
26-
},
27-
]);
28-
return resourceType;
29-
}
9+
const { resourceType } = await inquirer.prompt([
10+
{
11+
type: 'list',
12+
name: 'resourceType',
13+
message: 'Select the resource type:',
14+
choices: ['URL', 'PORT', 'GITHUB'],
15+
},
16+
]);
17+
return resourceType;
18+
}
19+
async function selectDockerPresent() {
20+
const { resourceType } = await inquirer.prompt([
21+
{
22+
type: 'list',
23+
name: 'resourceType',
24+
message: 'Is Dockerfile present?',
25+
choices: ['No', 'Yes'],
26+
},
27+
]);
28+
return resourceType;
29+
}
30+
31+
32+
async function selectStack() {
33+
const { Stack } = await inquirer.prompt([
34+
{
35+
type: 'list',
36+
name: 'Stack', // Must match the key you destructure
37+
message: 'Select the tech stack:',
38+
choices: ['Python', 'NodeJS'],
39+
},
40+
]);
41+
return Stack;
42+
}
3043

44+
export async function createDomain(userApiKey: string, user: string, provider: string, backendUrl: string) {
45+
let subdomain: string = '';
46+
let resourceType: string = '';
47+
let resource: string = '';
48+
let envContent: string = '';
49+
let staticContent: string = '';
50+
let dockerfilePresent: string = "";
51+
let port: string = '';
52+
let stack: string = '';
53+
let buildCmds: string = '';
3154

32-
async function selectStack() {
33-
const { Stack } = await inquirer.prompt([
34-
{
35-
type: 'list',
36-
name: 'Stack', // Must match the key you destructure
37-
message: 'Select the tech stack:',
38-
choices: ['Python', 'NodeJS'],
39-
},
40-
]);
41-
return Stack;
55+
subdomain = await promptUser('Enter subdomain (subdomain.domains.mdgspace.org):');
56+
resourceType = await selectResourceType();
57+
resource = await promptUser('Enter resource:');
58+
59+
if (resourceType === 'GitHub') {
60+
envContent = await promptUser('Enter environment content:');
61+
staticContent = await promptUser('Enter static content:');
62+
dockerfilePresent = await selectDockerPresent();
63+
port = await promptUser('Enter port:');
64+
stack = await promptUser('Enter stack (NodeJS/Python):');
65+
buildCmds = await promptUser('Enter build commands:');
4266
}
4367

44-
export async function createDomain(userApiKey : string, user : string , provider : string , backendUrl : string) {
45-
let subdomain : string = '';
46-
let resourceType : string = '';
47-
let resource : string= '';
48-
let envContent : string = '';
49-
let staticContent : string = '';
50-
let dockerfilePresent : string = "";
51-
let port : string = '';
52-
let stack : string = '';
53-
let buildCmds : string = '';
54-
55-
subdomain = await promptUser('Enter subdomain (subdomain.domains.mdgspace.org):');
56-
resourceType = await selectResourceType();
57-
resource = await promptUser('Enter resource:');
58-
59-
if (resourceType === 'GitHub') {
60-
envContent = await promptUser('Enter environment content:');
61-
staticContent = await promptUser('Enter static content:');
62-
dockerfilePresent =await selectDockerPresent();
63-
port = await promptUser('Enter port:');
64-
stack = await promptUser('Enter stack (NodeJS/Python):');
65-
buildCmds = await promptUser('Enter build commands:');
68+
const payload = {
69+
subdomain: `${subdomain}.${domain}`,
70+
resource_type: resourceType,
71+
resource,
72+
env_content: envContent,
73+
static_content: staticContent,
74+
dockerfile_present: dockerfilePresent,
75+
port,
76+
build_cmds: buildCmds,
77+
stack,
78+
author: user,
79+
date: new Date().toLocaleDateString(),
80+
token: userApiKey,
81+
provider,
82+
};
83+
try {
84+
const response = await axios.post(`${backendUrl}/map`, payload);
85+
if (response.data.status === 'success') {
86+
console.log(`✅ Domain '${subdomain}.${domain}' created successfully!`);
87+
} else {
88+
console.log('❌ Domain creation failed!');
89+
console.log("Either the domain exist or the domain is not created");
6690
}
67-
68-
const payload = {
69-
subdomain: `${subdomain}.${domain}`,
70-
resource_type: resourceType,
71-
resource,
72-
env_content: envContent,
73-
static_content: staticContent,
74-
dockerfile_present: dockerfilePresent,
75-
port,
76-
build_cmds: buildCmds,
77-
stack,
78-
author: user,
79-
date: new Date().toLocaleDateString(),
80-
token: userApiKey,
81-
provider,
82-
};
83-
try {
84-
const response = await axios.post(`${backendUrl}/map`, payload);
85-
if (response.data.status === 'success') {
86-
console.log(`✅ Domain '${subdomain}.${domain}' created successfully!`);
87-
} else {
88-
console.log('❌ Domain creation failed!');
89-
console.log("Either the domain exist or the domain is not created");
90-
}
91-
} catch (error) {
92-
console.error(chalk.red('Error creating domain:'));
93-
}
91+
} catch (error) {
92+
console.error(chalk.red('Error creating domain:'));
93+
}
9494
}

0 commit comments

Comments
 (0)