minor changes
This commit is contained in:
parent
909b29dfb5
commit
af2e220116
30 changed files with 598 additions and 350 deletions
|
|
@ -9,18 +9,18 @@ primary_region = 'sea'
|
|||
[build]
|
||||
|
||||
[[services]]
|
||||
protocol = 'tcp'
|
||||
internal_port = 8080
|
||||
auto_stop_machines = 'stop'
|
||||
auto_start_machines = true
|
||||
ports = [] # ✅ No public ports = no public IP
|
||||
protocol = 'tcp'
|
||||
internal_port = 8080
|
||||
auto_stop_machines = 'off'
|
||||
auto_start_machines = true
|
||||
ports = [] # ✅ No public ports = no public IP
|
||||
|
||||
[services.concurrency]
|
||||
type = 'requests'
|
||||
hard_limit = 1000
|
||||
soft_limit = 500
|
||||
[services.concurrency]
|
||||
type = 'requests'
|
||||
hard_limit = 1000
|
||||
soft_limit = 500
|
||||
|
||||
[[vm]]
|
||||
memory = '1gb'
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
memory = '1gb'
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
|
|
|
|||
107
assignment-service/package-lock.json
generated
107
assignment-service/package-lock.json
generated
|
|
@ -16,6 +16,7 @@
|
|||
"dotenv": "^16.5.0",
|
||||
"express": "^5.1.0",
|
||||
"express-session": "^1.18.1",
|
||||
"http-proxy-middleware": "^3.0.5",
|
||||
"multer": "^1.4.5-lts.2",
|
||||
"nodemon": "^3.1.9",
|
||||
"passport": "^0.7.0"
|
||||
|
|
@ -44,6 +45,24 @@
|
|||
"node-pre-gyp": "bin/node-pre-gyp"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/http-proxy": {
|
||||
"version": "1.17.16",
|
||||
"resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.16.tgz",
|
||||
"integrity": "sha512-sdWoUajOB1cd0A8cRRQ1cfyWNbmFKLAqBB89Y8x5iYyG/mkJHc0YUH8pdWBy2omi9qtCpiIgGjuwO0dQST2l5w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.15.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.29.tgz",
|
||||
"integrity": "sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/abbrev": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||
|
|
@ -755,6 +774,12 @@
|
|||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/eventemitter3": {
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
|
||||
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/events": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
|
||||
|
|
@ -1207,6 +1232,54 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy": {
|
||||
"version": "1.18.1",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
|
||||
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eventemitter3": "^4.0.0",
|
||||
"follow-redirects": "^1.0.0",
|
||||
"requires-port": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-middleware": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-3.0.5.tgz",
|
||||
"integrity": "sha512-GLZZm1X38BPY4lkXA01jhwxvDoOkkXqjgVyUzVxiEK4iuRu03PZoYHhHRwxnfhQMDuaxi3vVri0YgSro/1oWqg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/http-proxy": "^1.17.15",
|
||||
"debug": "^4.3.6",
|
||||
"http-proxy": "^1.18.1",
|
||||
"is-glob": "^4.0.3",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"micromatch": "^4.0.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-middleware/node_modules/debug": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
|
||||
|
|
@ -1384,6 +1457,15 @@
|
|||
"node": ">=0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-promise": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
|
||||
|
|
@ -1493,6 +1575,19 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.54.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
|
||||
|
|
@ -2053,6 +2148,12 @@
|
|||
"node": ">=8.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/requires-port": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
|
|
@ -2514,6 +2615,12 @@
|
|||
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"dotenv": "^16.5.0",
|
||||
"express": "^5.1.0",
|
||||
"express-session": "^1.18.1",
|
||||
"http-proxy-middleware": "^3.0.5",
|
||||
"multer": "^1.4.5-lts.2",
|
||||
"nodemon": "^3.1.9",
|
||||
"passport": "^0.7.0"
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ intructorRouter.get("/details/:id", async (req, res) => {
|
|||
);
|
||||
|
||||
console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);
|
||||
console.log("Response status:", response.status);
|
||||
res.status(response.status).json(response.data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching assignment details:", error.message);
|
||||
|
|
@ -129,16 +130,20 @@ intructorRouter.get(
|
|||
"/list/:id",
|
||||
// passport.authenticate("jwt", { session: false }),
|
||||
async (req, res) => {
|
||||
console.log("/list/:id endpoint hit");
|
||||
// if (req.isAuthenticated()) {
|
||||
try {
|
||||
const instructorId = req.params.id;
|
||||
// console.log("Fetching assignments for instructorId:", instructorId);
|
||||
console.log("Fetching assignments for instructorId:", instructorId);
|
||||
const response = await axios.get(
|
||||
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/instructor/${instructorId}`
|
||||
);
|
||||
// console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);
|
||||
console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);
|
||||
console.log("Response status:", response.status);
|
||||
res.status(response.status).json(response.data);
|
||||
} catch (error) {
|
||||
console.log("Error fetching assignments:", error.response);
|
||||
console.error("Error fetching assignments:", error.message);
|
||||
res.status(error.response?.status || 500).json({ error: error.message });
|
||||
}
|
||||
// } else {
|
||||
|
|
@ -191,10 +196,10 @@ intructorRouter.delete(
|
|||
|
||||
if (!assignmentData) {
|
||||
return res.status(404).json({ error: "Assignment not found" });
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the Battlesnake API
|
||||
if(assignmentData.appname){
|
||||
if (assignmentData.appname) {
|
||||
console.log(`Deleting Battlesnake API: ${assignmentData.appname}`);
|
||||
const deployResponse = await axios.post(`${DEPLOY_API_URL}/${assignmentData.appname}/delete`, {
|
||||
"appName": assignmentData.appname
|
||||
|
|
@ -206,7 +211,7 @@ intructorRouter.delete(
|
|||
}
|
||||
console.log('Response from DEPLOY_API_URL:', deployResponse.data);
|
||||
}
|
||||
|
||||
|
||||
console.log("Deleting assignment from database:", assignmentId);
|
||||
const response = await axios.delete(
|
||||
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`
|
||||
|
|
@ -231,7 +236,7 @@ intructorRouter.get(
|
|||
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/appname/${appName}`
|
||||
);
|
||||
console.log("Response data:", response.data);
|
||||
res.status(response.status).json({"exists": (response.data !== null && response.data !== undefined)});
|
||||
res.status(response.status).json({ "exists": (response.data !== null && response.data !== undefined) });
|
||||
} catch (error) {
|
||||
console.error("Error fetching assignment by app name:", error.message);
|
||||
res.status(error.response?.status || 500).json({ error: error.message });
|
||||
|
|
@ -251,7 +256,7 @@ intructorRouter.get(
|
|||
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrcode}`
|
||||
);
|
||||
console.log("Response data:", response.data);
|
||||
res.status(response.status).json({"exists": (response.data !== null && response.data !== undefined)});
|
||||
res.status(response.status).json({ "exists": (response.data !== null && response.data !== undefined) });
|
||||
} catch (error) {
|
||||
console.error("Error fetching assignment by QR code:", error.message);
|
||||
res.status(error.response?.status || 500).json({ error: error.message });
|
||||
|
|
|
|||
|
|
@ -7,24 +7,24 @@ const DB_ASSIGNMENT_SERVICE_URL = process.env.DB_ASSIGNMENT_SERVICE_URL;
|
|||
const DEPLOY_API_URL = process.env.DEPLOY_API_URL || "http://localhost:3600";
|
||||
|
||||
studentRouter.post("/save", async (req, res) => {
|
||||
//get the app name and code and save the latest jupyter file in s3 bucket
|
||||
const { appName, code } = req.body;
|
||||
//get the app name and code and save the latest jupyter file in s3 bucket
|
||||
const { appName, code } = req.body;
|
||||
|
||||
console.log("Received save request for app:", appName);
|
||||
console.log("Received save request for app:", appName);
|
||||
|
||||
const notebook = {
|
||||
cells: [
|
||||
const notebook = {
|
||||
cells: [
|
||||
{
|
||||
cell_type: "code",
|
||||
execution_count: null,
|
||||
metadata: {
|
||||
language: "python"
|
||||
language: "python"
|
||||
},
|
||||
outputs: [],
|
||||
source: code.split('\n').map(line => line + '\n')
|
||||
}
|
||||
],
|
||||
metadata: {
|
||||
],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
display_name: "Python 3",
|
||||
language: "python",
|
||||
|
|
@ -34,36 +34,36 @@ studentRouter.post("/save", async (req, res) => {
|
|||
name: "python",
|
||||
version: "3.x"
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
|
||||
// Convert the notebook object to a JSON string and then to base64
|
||||
const jsonString = JSON.stringify(notebook, null, 2);
|
||||
const base64 = Buffer.from(jsonString, 'utf-8').toString('base64');
|
||||
// Convert the notebook object to a JSON string and then to base64
|
||||
const jsonString = JSON.stringify(notebook, null, 2);
|
||||
const base64 = Buffer.from(jsonString, 'utf-8').toString('base64');
|
||||
|
||||
const notebookName = `${Date.now()}-notebook.ipynb`;
|
||||
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
||||
console.log("Uploading notebook:", notebookName, "to app:", appName);
|
||||
const notebookName = `${Date.now()}-notebook.ipynb`;
|
||||
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
||||
console.log("Uploading notebook:", notebookName, "to app:", appName);
|
||||
|
||||
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ notebookName: notebookName, fileContentBase64: base64 })
|
||||
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ notebookName: notebookName, fileContentBase64: base64 })
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error("Failed to save notebook");
|
||||
return response.json();
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error("Failed to save notebook");
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log("Notebook saved successfully:", data);
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error saving notebook:", error.message);
|
||||
res.status(500).json({ error: error.message });
|
||||
});
|
||||
.then((data) => {
|
||||
console.log("Notebook saved successfully:", data);
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error saving notebook:", error.message);
|
||||
res.status(500).json({ error: error.message });
|
||||
});
|
||||
});
|
||||
|
||||
studentRouter.get("/assignment/:qrnum", (req, res) => {
|
||||
|
|
@ -105,7 +105,7 @@ studentRouter.post("/verify", async (req, res) => {
|
|||
|
||||
const isPasswordValid = await bcrypt.compare(
|
||||
password,
|
||||
response.data.passwordhash
|
||||
response.data.passwordhash
|
||||
);
|
||||
|
||||
console.log("Password validation result:", isPasswordValid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue