All files / util app.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 282x 2x   2x 2x 9x   2x         3x             3x 3x   3x 3x        
import {BasicCollection} from "../src/collection-basic";
import {RhizomeNode, RhizomeNodeConfig} from "../src/node";
 
const start = 5000;
const range = 5000;
const getRandomPort = () => Math.floor(start + range * Math.random());
 
export class App extends RhizomeNode {
  apiUrl: string;
 
  constructor(config?: Partial<RhizomeNodeConfig>) {
    // Randomizing ports to try to avoid collisions between tests.
    super({
      publishBindPort: getRandomPort(),
      requestBindPort: getRandomPort(),
      httpPort: getRandomPort(),
      ...config,
    });
 
    const users = new BasicCollection("user");
    users.rhizomeConnect(this);
 
    const {httpAddr, httpPort} = this.config;
    this.apiUrl = `http://${httpAddr}:${httpPort}/api`;
  }
}