Merge pull request #24 from JBB0807/deployment-prep
bug fix for saving and restarting notebook
This commit is contained in:
commit
1ebe18b1e8
4 changed files with 54 additions and 44 deletions
|
|
@ -10,6 +10,8 @@ studentRouter.post("/save", async (req, res) => {
|
||||||
//get the app name and code and save the latest jupyter file in s3 bucket
|
//get the app name and code and save the latest jupyter file in s3 bucket
|
||||||
const { appName, code } = req.body;
|
const { appName, code } = req.body;
|
||||||
|
|
||||||
|
console.log("Received save request for app:", appName);
|
||||||
|
|
||||||
const notebook = {
|
const notebook = {
|
||||||
cells: [
|
cells: [
|
||||||
{
|
{
|
||||||
|
|
@ -43,6 +45,8 @@ studentRouter.post("/save", async (req, res) => {
|
||||||
|
|
||||||
const notebookName = `${Date.now()}-notebook.ipynb`;
|
const notebookName = `${Date.now()}-notebook.ipynb`;
|
||||||
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
||||||
|
console.log("Uploading notebook:", notebookName, "to app:", appName);
|
||||||
|
|
||||||
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,22 @@ const api = require("express").Router();
|
||||||
|
|
||||||
const ASSIGNMENT_SERVICE_URL = process.env.ASSIGNMENT_SERVICE_URL;
|
const ASSIGNMENT_SERVICE_URL = process.env.ASSIGNMENT_SERVICE_URL;
|
||||||
|
|
||||||
// rerout to asisgnment url
|
|
||||||
api.use((req, res, next) => {
|
|
||||||
console.log(`Proxying request to: ${ASSIGNMENT_SERVICE_URL} : original url : ${req.originalUrl}`);
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
api.use(
|
api.use(
|
||||||
'/',
|
'/',
|
||||||
createProxyMiddleware({
|
createProxyMiddleware({
|
||||||
target: ASSIGNMENT_SERVICE_URL,
|
target: ASSIGNMENT_SERVICE_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
logLevel: 'debug',
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
'^/api': '', // only remove /api
|
'^/api': '', // remove "/api" from the start
|
||||||
},
|
},
|
||||||
|
onProxyReq(proxyReq, req, res) {
|
||||||
|
console.log(`Proxying request to: ${ASSIGNMENT_SERVICE_URL}${req.url}`);
|
||||||
|
},
|
||||||
|
onError(err, req, res) {
|
||||||
|
console.error('Proxy error:', err.message);
|
||||||
|
res.status(502).send('Bad Gateway: Failed to connect to target');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@ const auth = require("express").Router();
|
||||||
const passport = require("passport");
|
const passport = require("passport");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
|
||||||
|
const express = require("express");
|
||||||
|
|
||||||
|
const bodyParser = require("body-parser");
|
||||||
|
|
||||||
|
auth.use(express.json());
|
||||||
|
auth.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
const AUTH_URL = process.env.AUTH_URL || "http://localhost:8080";
|
const AUTH_URL = process.env.AUTH_URL || "http://localhost:8080";
|
||||||
|
|
||||||
auth.get(
|
auth.get(
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,8 @@ const passportSetup = require("./passport");
|
||||||
const authRoute = require("./routes/auth");
|
const authRoute = require("./routes/auth");
|
||||||
const apiRoute = require("./routes/api");
|
const apiRoute = require("./routes/api");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
const bodyParser = require("body-parser");
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
|
||||||
|
|
||||||
// console.log("AUTH_URL:", process.env.AUTH_URL);
|
// console.log("AUTH_URL:", process.env.AUTH_URL);
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue