🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

mongodb-memory-server-core

Package Overview
Dependencies
Maintainers
1
Versions
280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-memory-server-core - npm Package Compare versions

Comparing version

to
6.0.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [6.0.1](https://github.com/nodkz/mongodb-memory-server/compare/v6.0.0...v6.0.1) (2019-10-22)
### Bug Fixes
* **MongoMemoryServer:** add `?` character to the connection string (uri) by default (hotfix for v6.0.0) ([505b7c2](https://github.com/nodkz/mongodb-memory-server/commit/505b7c2))
# [6.0.0](https://github.com/nodkz/mongodb-memory-server/compare/v5.2.11...v6.0.0) (2019-10-22)

@@ -8,0 +19,0 @@

2

lib/MongoMemoryServer.d.ts

@@ -17,2 +17,3 @@ /// <reference types="node" />

dbName: string;
ip: string;
uri: string;

@@ -39,2 +40,3 @@ storageEngine: StorageEngineT;

ensureInstance(): Promise<MongoInstanceDataT>;
_getUriBase(host: string, port: number, dbName: string): string;
getUri(otherDbName?: string | boolean): Promise<string>;

@@ -41,0 +43,0 @@ getConnectionString(otherDbName?: string | boolean): Promise<string>;

39

lib/MongoMemoryServer.js

@@ -59,7 +59,2 @@ "use strict";

tmp_1.default.setGracefulCleanup();
var generateConnectionString = function (port, dbName) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, "mongodb://127.0.0.1:" + port + "/" + dbName];
});
}); };
var MongoMemoryServer = /** @class */ (function () {

@@ -121,15 +116,16 @@ function MongoMemoryServer(opts) {

data = {};
instOpts = this.opts.instance;
instOpts = this.opts.instance || {};
_a = data;
return [4 /*yield*/, get_port_1.default({ port: (instOpts && instOpts.port) || undefined })];
return [4 /*yield*/, get_port_1.default({ port: instOpts.port || undefined })];
case 1:
_a.port = _c.sent();
data.dbName = db_util_1.generateDbName(instOpts && instOpts.dbName);
data.dbName = db_util_1.generateDbName(instOpts.dbName);
data.ip = instOpts.ip || '127.0.0.1';
_b = data;
return [4 /*yield*/, generateConnectionString(data.port, data.dbName)];
return [4 /*yield*/, this._getUriBase(data.ip, data.port, data.dbName)];
case 2:
_b.uri = _c.sent();
data.storageEngine = (instOpts && instOpts.storageEngine) || 'ephemeralForTest';
data.replSet = instOpts && instOpts.replSet;
if (instOpts && instOpts.dbPath) {
data.storageEngine = instOpts.storageEngine || 'ephemeralForTest';
data.replSet = instOpts.replSet;
if (instOpts.dbPath) {
data.dbPath = instOpts.dbPath;

@@ -150,9 +146,9 @@ }

dbPath: data.dbPath,
debug: this.opts.instance && this.opts.instance.debug,
ip: data.ip,
port: data.port,
storageEngine: data.storageEngine,
replSet: data.replSet,
args: this.opts.instance && this.opts.instance.args,
auth: this.opts.instance && this.opts.instance.auth,
ip: this.opts.instance && this.opts.instance.ip,
debug: instOpts.debug,
args: instOpts.args,
auth: instOpts.auth,
},

@@ -222,6 +218,9 @@ binary: this.opts.binary,

};
MongoMemoryServer.prototype._getUriBase = function (host, port, dbName) {
return "mongodb://" + host + ":" + port + "/" + dbName + "?";
};
MongoMemoryServer.prototype.getUri = function (otherDbName) {
if (otherDbName === void 0) { otherDbName = false; }
return __awaiter(this, void 0, void 0, function () {
var _a, uri, port;
var _a, uri, port, ip;
return __generator(this, function (_b) {

@@ -231,3 +230,3 @@ switch (_b.label) {

case 1:
_a = _b.sent(), uri = _a.uri, port = _a.port;
_a = _b.sent(), uri = _a.uri, port = _a.port, ip = _a.ip;
// IF true OR string

@@ -237,6 +236,6 @@ if (otherDbName) {

// generate uri with provided DB name on existed DB instance
return [2 /*return*/, generateConnectionString(port, otherDbName)];
return [2 /*return*/, this._getUriBase(ip, port, otherDbName)];
}
// generate new random db name
return [2 /*return*/, generateConnectionString(port, db_util_1.generateDbName())];
return [2 /*return*/, this._getUriBase(ip, port, db_util_1.generateDbName())];
}

@@ -243,0 +242,0 @@ return [2 /*return*/, uri];

{
"name": "mongodb-memory-server-core",
"version": "6.0.0",
"version": "6.0.1",
"description": "MongoDB Server for testing (core package, without autodownload). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",

@@ -75,3 +75,3 @@ "main": "lib/index",

},
"gitHead": "a5b419052547395c20e21d7ed4656a6b412c225b"
"gitHead": "04a0a8c6533c791cd2704d5c037eca4f6ae74622"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet