Skip to content

Commit

Permalink
fix(Flowtype): Fix Flow declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 5, 2017
1 parent 829be44 commit 4b3dc91
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import getport from 'get-port';
tmp.setGracefulCleanup();

export type MongoMemoryServerOptsT = {
port?: number,
port?: ?number,
storageEngine?: string,
dbPath?: string,
autoStart?: boolean,
Expand All @@ -21,9 +21,13 @@ export type MongoInstanceDataT = {
uri: string,
storageEngine: string,
mongodCli: MongodHelper,
tmpDir?: {
name: string,
removeCallback: Function,
},
};

async function generateConnectionString(port: string, dbName: ?string): Promise<string> {
async function generateConnectionString(port: number, dbName: ?string): Promise<string> {
const db = dbName || (await uuid());
return `mongodb://localhost:${port}/${db}`;
}
Expand Down Expand Up @@ -118,7 +122,7 @@ export default class MongoDBMemoryServer {
}

async stop(): Promise<boolean> {
const { mongodCli, port, tmpDir } = await this.getInstanceData();
const { mongodCli, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT);

if (mongodCli && mongodCli.mongoBin.childProcess) {
// .mongoBin.childProcess.connected
Expand Down Expand Up @@ -147,7 +151,7 @@ export default class MongoDBMemoryServer {
}

async getUri(otherDbName?: string | boolean = false): Promise<string> {
const { uri, port } = await this.getInstanceData();
const { uri, port } = (await this.getInstanceData(): MongoInstanceDataT);

// IF true OR string
if (otherDbName) {
Expand All @@ -167,12 +171,12 @@ export default class MongoDBMemoryServer {
}

async getPort(): Promise<number> {
const { port } = await this.getInstanceData();
const { port } = (await this.getInstanceData(): MongoInstanceDataT);
return port;
}

async getDbPath(): Promise<string> {
const { port } = await this.getInstanceData();
return port;
const { dbPath } = (await this.getInstanceData(): MongoInstanceDataT);
return dbPath;
}
}

0 comments on commit 4b3dc91

Please sign in to comment.