UNPKG

azurite

Version:

An open source Azure Storage API compatible server

53 lines 3.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlobServerFactory = void 0; const tslib_1 = require("tslib"); const path_1 = require("path"); const constants_1 = require("../common/utils/constants"); const BlobConfiguration_1 = tslib_1.__importDefault(require("./BlobConfiguration")); const BlobEnvironment_1 = tslib_1.__importDefault(require("./BlobEnvironment")); const BlobServer_1 = tslib_1.__importDefault(require("./BlobServer")); const SqlBlobConfiguration_1 = tslib_1.__importDefault(require("./SqlBlobConfiguration")); const SqlBlobServer_1 = tslib_1.__importDefault(require("./SqlBlobServer")); const constants_2 = require("./utils/constants"); const constants_3 = require("./utils/constants"); class BlobServerFactory { async createServer(blobEnvironment) { // TODO: Check it's in Visual Studio Code environment or not const isVSC = false; if (!isVSC) { const env = blobEnvironment ? blobEnvironment : new BlobEnvironment_1.default(); const location = await env.location(); const debugFilePath = await env.debug(); if (typeof debugFilePath === "boolean") { throw RangeError(`Must provide a debug log file path for parameter -d or --debug`); } constants_3.DEFAULT_BLOB_PERSISTENCE_ARRAY[0].locationPath = (0, path_1.join)(location, constants_2.DEFAULT_BLOB_PERSISTENCE_PATH); // TODO: Check we need to create blob server against SQL or Loki const databaseConnectionString = process.env.AZURITE_DB; const isSQL = databaseConnectionString !== undefined; if (isSQL) { if (env.inMemoryPersistence()) { throw new Error(`The --inMemoryPersistence option is not supported when using SQL-based metadata storage.`); } if (env.extentMemoryLimit() !== undefined) { throw new Error(`The --extentMemoryLimit option is not supported when using SQL-based metadata storage.`); } const config = new SqlBlobConfiguration_1.default(env.blobHost(), env.blobPort(), databaseConnectionString, constants_1.DEFAULT_SQL_OPTIONS, constants_3.DEFAULT_BLOB_PERSISTENCE_ARRAY, !env.silent(), undefined, debugFilePath !== undefined, debugFilePath, env.loose(), env.skipApiVersionCheck(), env.cert(), env.key(), env.pwd(), env.oauth(), env.disableProductStyleUrl()); return new SqlBlobServer_1.default(config); } else { const config = new BlobConfiguration_1.default(env.blobHost(), env.blobPort(), (0, path_1.join)(location, constants_3.DEFAULT_BLOB_LOKI_DB_PATH), (0, path_1.join)(location, constants_3.DEFAULT_BLOB_EXTENT_LOKI_DB_PATH), constants_3.DEFAULT_BLOB_PERSISTENCE_ARRAY, !env.silent(), undefined, debugFilePath !== undefined, debugFilePath, env.loose(), env.skipApiVersionCheck(), env.cert(), env.key(), env.pwd(), env.oauth(), env.disableProductStyleUrl(), env.inMemoryPersistence()); return new BlobServer_1.default(config); } } else { // TODO: Add BlobServer construction in VSC // Visual Studio Code Loki // Visual Studio Code SQL throw new Error("Not implemented."); } } } exports.BlobServerFactory = BlobServerFactory; //# sourceMappingURL=BlobServerFactory.js.map