import { join } from "path" ; import { DEFAULT_SQL_OPTIONS } from "../common/utils/constants" ; import BlobConfiguration from "./BlobConfiguration" ; import BlobEnvironment from "./BlobEnvironment" ; import BlobServer from "./BlobServer" ; import IBlobEnvironment from "./IBlobEnvironment" ; import SqlBlobConfiguration from "./SqlBlobConfiguration" ; import SqlBlobServer from "./SqlBlobServer" ; import { DEFAULT_BLOB_PERSISTENCE_PATH } from "./utils/constants" ; import { DEFAULT_BLOB_EXTENT_LOKI_DB_PATH , DEFAULT_BLOB_LOKI_DB_PATH , DEFAULT_BLOB_PERSISTENCE_ARRAY } from "./utils/constants" ; export class BlobServerFactory { public async createServer ( blobEnvironment ? ) { const isVSC = false ; if ( ! isVSC ) { const env = blobEnvironment ? blobEnvironment : new BlobEnvironment ( ) ; 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` ) ; } DEFAULT_BLOB_PERSISTENCE_ARRAY [ 0 ] . locationPath = join ( location , DEFAULT_BLOB_PERSISTENCE_PATH ) ; const databaseConnectionString = process . env . AZURITE_DB ; const isSQL = databaseConnectionString !== undefined ; if ( isSQL ) { const config = new SqlBlobConfiguration ( env . blobHost ( ) , env . blobPort ( ) , databaseConnectionString ! , DEFAULT_SQL_OPTIONS , 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 ( config ) ; } else { const config = new BlobConfiguration ( env . blobHost ( ) , env . blobPort ( ) , join ( location , DEFAULT_BLOB_LOKI_DB_PATH ) , join ( location , DEFAULT_BLOB_EXTENT_LOKI_DB_PATH ) , 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 BlobServer ( config ) ; } } else { throw new Error ( "Not implemented." ) ; } } }