From 8cf4a94355374c02795d5a077cdf9308b7fa0090 Mon Sep 17 00:00:00 2001 From: Sung-Hyun Kang Date: Thu, 30 Oct 2025 15:33:40 -0500 Subject: [PATCH] Add parameterized ejs --- src/quickstart-sql.template.ejs | 179 ++++++++++++++++++++++++++++++++ webpack.config.js | 39 +++++-- 2 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 src/quickstart-sql.template.ejs diff --git a/src/quickstart-sql.template.ejs b/src/quickstart-sql.template.ejs new file mode 100644 index 000000000..16686c9bc --- /dev/null +++ b/src/quickstart-sql.template.ejs @@ -0,0 +1,179 @@ + + + + + + Azure Cosmos DB Emulator (SQL) + + +
+
+

Congratulations! Your Azure Cosmos DB emulator is running.

+

Now, let's connect a sample app to it.

+
+

URI

+ +

Primary Key

+ +

Primary Connection String

+ +
+

Choose a platform

+
+
+ +
+
+
+
1
+
+ Create a new .NET app +

+ Follow this + tutorial + to create a new .NET app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
1
+
+ Create a new Java app +

+ Follow this + tutorial + to create a new Java app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
1
+
+ Create a new Node.js app +

+ Follow this + tutorial + to create a new Node.js app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
1
+
+ Create a new Python app +

+ Follow this tutorial + to create a new Python app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
1
+
+ Create a new Go app +

+ Follow this + tutorial + to create a new Go app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
1
+
+ Create a new Spring Boot app +

+ Follow this + tutorial + to create a new Spring Boot app connected to Azure Cosmos DB. +

+
+
+
+
+
+
+
+ + + + + + diff --git a/webpack.config.js b/webpack.config.js index f6fba7c1b..af96dc702 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -122,6 +122,23 @@ module.exports = function (_env = {}, argv = {}) { ...(mode !== "production" && { testExplorer: "./test/testExplorer/TestExplorer.ts" }), }; + // Derive emulator endpoint components from EMULATOR_ENDPOINT (fallback to localhost defaults) + const rawEndpoint = process.env.EMULATOR_ENDPOINT || (ishttps ? "https://localhost:8081/" : "http://localhost:8081/"); + let endpointProtocol = ishttps ? "https" : "http"; + let endpointHost = "localhost"; + let endpointPort = "8081"; + try { + const u = new URL(rawEndpoint); + endpointProtocol = u.protocol.replace(":", ""); + endpointHost = u.hostname; + endpointPort = u.port || (endpointProtocol === "https" ? "443" : "80"); + } catch (e) { + // Ignore parse errors and keep defaults + } + const endpointUri = `${endpointProtocol}://${endpointHost}:${endpointPort}`; + const primaryKeyConst = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; + const primaryConnString = `AccountEndpoint=${endpointUri}/;AccountKey=${primaryKeyConst}`; + const htmlWebpackPlugins = [ new HtmlWebpackPlugin({ filename: "explorer.html", @@ -134,17 +151,16 @@ module.exports = function (_env = {}, argv = {}) { chunks: ["terminal"], }), //todo - dynamically include apis - ishttps - ? new HtmlWebpackPlugin({ - filename: "quickstart.html", - template: "src/quickstart-sql-only.html", - chunks: ["quickstart"], - }) - : new HtmlWebpackPlugin({ - filename: "quickstart.html", - template: "src/quickstart-sql-only-http.html", - chunks: ["quickstart"], - }), + new HtmlWebpackPlugin({ + filename: "quickstart.html", + template: "src/quickstart-sql.template.ejs", + chunks: ["quickstart"], + templateParameters: { + endpointUri, + primaryKey: primaryKeyConst, + primaryConnString, + }, + }), new HtmlWebpackPlugin({ filename: "index.html", template: "src/index.html", @@ -220,6 +236,7 @@ module.exports = function (_env = {}, argv = {}) { { from: "DataExplorer.proj" }, { from: "web.config" }, { from: "quickstart/*.zip" }, + { from: "images", to: "images" }, ], }), new EnvironmentPlugin(envVars),