UNPKG

kindagoose

Version:
51 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MongoDBConnectionURIBuilder = void 0; class MongoDBConnectionURIBuilder { constructor() { this.protocol = ''; this.hostname = ''; this.port = ''; this.username = ''; this.password = ''; this.databaseName = ''; this.connectionParams = ''; } setProtocol(protocol) { this.protocol = protocol; return this; } setHostname(hostname) { this.hostname = hostname; return this; } setPort(port) { this.port = ':' + port; return this; } setUsername(username) { this.username = username; return this; } setPassword(password) { this.password = password + '@'; return this; } setDatabaseName(dbName) { this.databaseName = dbName; return this; } /** * * @param {string} params - string like `param1=value1&param2=value2` */ setConnectionParams(params) { this.connectionParams = params; return this; } build() { return `${this.protocol}/${this.username}/${this.password}${this.hostname}${this.port}/${this.databaseName}?${this.connectionParams}`; } } exports.MongoDBConnectionURIBuilder = MongoDBConnectionURIBuilder; //# sourceMappingURL=mongodb-connection-uri-builder.js.map