Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add swaggger spec and remove V3 support #300

Merged
merged 4 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove legacy V3 support
  • Loading branch information
haimkastner committed Sep 9, 2023
commit d36a6ae3e5260a8f1f0cdf2916559fbee9e876f3
2 changes: 0 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
"pkg": {
"assets": [
"versionInfo.json",
"public/**/*",
"swagger.json",
"dashboard/**/*",
"casaqueue/**/*",
"docs/**/*"
]
},
Expand Down
16 changes: 0 additions & 16 deletions backend/scripts/fetchDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import jsZip from 'jszip';
import nodeFetch from 'node-fetch';

const dashboardDist = path.join('dist', 'dashboard');
const legacyDashboardDist = path.join('dist', 'public');
const casaqueueDashboardDist = path.join('dist', 'casaqueue');

const ENV_BRANCH = process.env.BRANCH !== 'master' ? 'develop' : 'main';

Expand Down Expand Up @@ -38,18 +36,4 @@ async function downloadAndUnpackDashboard(dashboardArtifact, distDir) {
} catch (error) {
console.error(`[fetchDashboard] Fetching "dashboard-app" for branch "${process.env.BRANCH}" from dashboard "${ENV_BRANCH}" branch failed ${error.message}`);
}

try {
// Download the legacy v3 front dashboard
await downloadAndUnpackDashboard(`https://nightly.link/casanet/frontend-v3/workflows/nodejs/${ENV_BRANCH}/internal.zip`, legacyDashboardDist);
} catch (error) {
console.error(`[fetchDashboard] Fetching "frontend-v3" for branch "${process.env.BRANCH}" from dashboard "${ENV_BRANCH}" branch failed ${error.message}`);
}

try {
// Download the casa queue view
await downloadAndUnpackDashboard(`https://nightly.link/casanet/casaqueue-dashboard/workflows/build/${ENV_BRANCH}/internal.zip`, casaqueueDashboardDist);
} catch (error) {
console.error(`[fetchDashboard] Fetching "casaqueue-dashboard" for branch "${process.env.BRANCH}" from dashboard "${ENV_BRANCH}" branch failed ${error.message}`);
}
})();
64 changes: 0 additions & 64 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class App {

/** Serve static client side assets */
this.serveDashboard();
this.serveLegacyDashboard();
this.serveCasaqueueDashboard();

/** Serve swagger docs UI */
this.serveDocs();
Expand All @@ -59,68 +57,6 @@ class App {
this.catchErrors();
}

/**
* Serve static files of front-end.
*/
private serveLegacyDashboard() {
/** In / path only serve the index.html file */
this.express.get('/v3', (req: express.Request, res: express.Response) =>
res.sendFile(path.join(__dirname, '/public/index.html')),
);

/** Get any file in public directory */
this.express.use(async (req: express.Request, res: express.Response, next: express.NextFunction) => {

// The v3 dashboard assets placed in the public dir, so redirect thr V3 requests to there.
let url = req.url || '';
if (url.startsWith('v3') || url.startsWith('/v3')) {
url = url.replace('v3', 'public');
} else {
next();
return;
}

const filePath = path.join(__dirname, url);
fse.exists(filePath, exists => {
if (exists) {
res.sendFile(filePath);
} else {
next();
}
});
});
}

/**
* Serve static files of front-end.
*/
private serveCasaqueueDashboard() {
/** In /casaqueue path only serve the index.html file */
this.express.get('/casaqueue', (req: express.Request, res: express.Response) =>
res.sendFile(path.join(__dirname, '/casaqueue/index.html')),
);

/** Get any file in public directory */
this.express.use(async (req: express.Request, res: express.Response, next: express.NextFunction) => {

// The casaqueue assets placed in the casaqueue dir, so redirect the casaqueue requests to there.
let url = req.url || '';
if (!url.startsWith('casaqueue') && !url.startsWith('/casaqueue')) {
next();
return;
}

const filePath = path.join(__dirname, url);
fse.exists(filePath, exists => {
if (exists) {
res.sendFile(filePath);
} else {
next();
}
});
});
}

/**
* Serve new dashboard files.
*/
Expand Down
10 changes: 5 additions & 5 deletions backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,11 @@ accepts@~1.3.8:
mime-types "~2.1.34"
negotiator "0.6.3"

address@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/address/-/address-1.2.2.tgz#2b5248dac5485a6390532c6a517fda2e3faac89e"
integrity sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==

adm-zip@^0.4.14:
version "0.4.16"
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365"
Expand Down Expand Up @@ -3883,11 +3888,6 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

macaddress@^0.2.9:
version "0.2.9"
resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.9.tgz#3579b8b9acd5b96b4553abf0f394185a86813cb3"
integrity sha512-k4F1JUof6cQXxNFzx3thLby4oJzXTXQueAOOts944Vqizn+Rjc2QNFenT9FJSLU1CH3PmrHRSyZs2E+Cqw+P2w==

make-dir@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
Expand Down
Loading