mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 19:01:28 +00:00
Compare commits
3 Commits
eslint/fix
...
users/artr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c287770d7 | ||
|
|
6ce45fd04b | ||
|
|
e4e602a81e |
@@ -6,6 +6,7 @@ import * as DataModels from "../Contracts/DataModels";
|
|||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
import { Collection } from "../Contracts/ViewModels";
|
import { Collection } from "../Contracts/ViewModels";
|
||||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||||
|
import { hasFlag } from "../Platform/Hosted/extractFeatures";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import { ApiType, HttpHeaders, HttpStatusCodes } from "./Constants";
|
import { ApiType, HttpHeaders, HttpStatusCodes } from "./Constants";
|
||||||
@@ -141,7 +142,8 @@ export function readDocument(
|
|||||||
: "",
|
: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
const endpoint = getEndpoint();
|
const endpoint = getFeatureEndpointOrDefault("readDocument");
|
||||||
|
|
||||||
return window
|
return window
|
||||||
.fetch(`${endpoint}?${queryString.stringify(params)}`, {
|
.fetch(`${endpoint}?${queryString.stringify(params)}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -342,6 +344,10 @@ export function getEndpoint(): string {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFeatureEndpointOrDefault(feature: string): string {
|
||||||
|
return (hasFlag("mongoProxyFeatures", feature)) ? userContext.features.mongoProxyEndpoint : getEndpoint();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: This function throws most of the time except on Forbidden which is a bit strange
|
// TODO: This function throws most of the time except on Forbidden which is a bit strange
|
||||||
// It causes problems for TypeScript understanding the types
|
// It causes problems for TypeScript understanding the types
|
||||||
async function errorHandling(response: Response, action: string, params: unknown): Promise<void> {
|
async function errorHandling(response: Response, action: string, params: unknown): Promise<void> {
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ export type Features = {
|
|||||||
readonly pr?: string;
|
readonly pr?: string;
|
||||||
readonly showMinRUSurvey: boolean;
|
readonly showMinRUSurvey: boolean;
|
||||||
readonly ttl90Days: boolean;
|
readonly ttl90Days: boolean;
|
||||||
|
readonly mongoProxyEndpoint: string;
|
||||||
|
readonly mongoProxyFeatures: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function extractFeatures(given = new URLSearchParams(window.location.search)): Features {
|
export function extractFeatures(given = new URLSearchParams(window.location.search)): Features {
|
||||||
@@ -58,6 +60,8 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
|||||||
enableTtl: "true" === get("enablettl"),
|
enableTtl: "true" === get("enablettl"),
|
||||||
executeSproc: "true" === get("dataexplorerexecutesproc"),
|
executeSproc: "true" === get("dataexplorerexecutesproc"),
|
||||||
hostedDataExplorer: "true" === get("hosteddataexplorerenabled"),
|
hostedDataExplorer: "true" === get("hosteddataexplorerenabled"),
|
||||||
|
mongoProxyEndpoint: get("mongoproxyendpoint"),
|
||||||
|
mongoProxyFeatures: get("mongoproxyfeatures"),
|
||||||
junoEndpoint: get("junoendpoint"),
|
junoEndpoint: get("junoendpoint"),
|
||||||
livyEndpoint: get("livyendpoint"),
|
livyEndpoint: get("livyendpoint"),
|
||||||
notebookBasePath: get("notebookbasepath"),
|
notebookBasePath: get("notebookbasepath"),
|
||||||
@@ -72,3 +76,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
|||||||
partitionKeyDefault: "true" === get("partitionkeytest"),
|
partitionKeyDefault: "true" === get("partitionkeytest"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasFlag(value: string, flag: string): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -264,6 +264,17 @@ module.exports = function (_env = {}, argv = {}) {
|
|||||||
"Access-Control-Allow-Methods": "*",
|
"Access-Control-Allow-Methods": "*",
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
|
"/api/mongo": {
|
||||||
|
target: "https://juno-test2.documents-dev.windows-int.net/api/mongo/test",
|
||||||
|
changeOrigin: true,
|
||||||
|
logLevel: "debug",
|
||||||
|
bypass: (req, res) => {
|
||||||
|
if (req.method === "OPTIONS") {
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.send();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
"/api": {
|
"/api": {
|
||||||
target: "https://main.documentdb.ext.azure.com",
|
target: "https://main.documentdb.ext.azure.com",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user