Skip to content

Commit

Permalink
DOP-3960 dev endpoints for API specs
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar committed Nov 16, 2023
1 parent f97d340 commit 2d7a768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions modules/oas-page-builder/src/services/pageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import { findLastSavedVersionData, saveSuccessfulBuildVersionData } from './data
import { VersionData } from './models/OASFile';
import { normalizeUrl } from '../utils/normalizeUrl';

const OAS_FILE_SERVER = 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/';
const GIT_HASH_URL = 'https://cloud.mongodb.com/version';
const env = process.env.SNOOTY_ENV ?? '';

const OAS_FILE_SERVER =
env === 'dotcomprd'
? 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/'
: 'http://mongodb-mms-build-server.s3.amazonaws.com/openapi/';

const GIT_HASH_URL =
env === 'dotcomprd' ? 'https://cloud.mongodb.com/version' : ' https://cloud-dev.mongodb.com/version';

const fetchTextData = async (url: string, errMsg: string) => {
const res = await fetch(url);
Expand Down Expand Up @@ -274,7 +281,7 @@ export const buildOpenAPIPages = async (
if (totalSuccess && sourceType == 'atlas') {
try {
const gitHash = await fetchGitHash();
const versions = await fetchVersionData(gitHash);
const versions = await fetchVersionData(gitHash, OAS_FILE_SERVER);
await saveSuccessfulBuildVersionData(source, gitHash, versions);
} catch (e) {
console.error(e);
Expand Down
4 changes: 2 additions & 2 deletions modules/oas-page-builder/src/utils/fetchVersionData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetch from 'node-fetch';

export const fetchVersionData = async (gitHash: string) => {
const versionUrl = `https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/${gitHash}-api-versions.json`;
export const fetchVersionData = async (gitHash: string, serverURL: string) => {
const versionUrl = `${serverURL}${gitHash}-api-versions.json`;
const res = await fetch(versionUrl);
const { versions } = await res.json();
return versions;
Expand Down

0 comments on commit 2d7a768

Please sign in to comment.