fix(core): update

This commit is contained in:
2021-12-20 15:58:23 +01:00
commit 65cbc97e83
13 changed files with 28222 additions and 0 deletions

36
ts/index.ts Normal file
View File

@ -0,0 +1,36 @@
import * as plugins from './smartmongo.plugins';
export class SmartMongo {
// STATIC
public static async createInstance() {
const smartMongoInstance = new SmartMongo();
await smartMongoInstance.readyPromise;
return smartMongoInstance;
}
// INSTANCE
private _readyDeferred = plugins.smartpromise.defer();
public readyPromise = this._readyDeferred.promise;
public mongod: plugins.mongoPlugin.MongoMemoryServer;
constructor() {
this.init();
}
public async init() {
this.mongod = await plugins.mongoPlugin.MongoMemoryServer.create();
this._readyDeferred.resolve();
console.log('mongod started');
}
public async getMongoDescriptor() {
await this.readyPromise;
return {
mongoDbUrl: this.mongod.getUri(),
}
}
public async stop() {
this.mongod.stop();
}
}

11
ts/smartmongo.plugins.ts Normal file
View File

@ -0,0 +1,11 @@
// @pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
export {
smartpromise
}
// thirdparty
import * as mongoPlugin from 'mongodb-memory-server';
export { mongoPlugin };