All files / blong-gogo/src ResolutionLocal.ts

90.24% Statements 37/41
90% Branches 9/10
75% Functions 9/12
90.24% Lines 37/41

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 421x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x       1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {Internal} from '@feasibleone/blong/types';
 
import type {IResolution} from './Resolution.ts';
 
interface IConfig {
    portRpc: number;
    portGateway: number;
    domain: string;
}
export default class ResolutionLocal extends Internal implements IResolution {
    #config: IConfig = {
        portRpc: 8091,
        portGateway: 8080,
        domain: 'localhost',
    };
 
    public constructor(config: IConfig) {
        super();
        this.merge(this.#config, config);
    }

    public async resolve(
        service: string,
        // invalidate: boolean,
        // namespace: string,
    ): ReturnType<IResolution['resolve']> {
        return {
            // hostname: `${service}-service.${this.#config.domain}`,
            hostname: 'localhost',
            port: service.startsWith('rpc-')
                ? `${this.#config.portRpc}`
                : `${this.#config.portGateway}`,
        };
    }
 
    public announce(): void {}
 
    public async start(): Promise<void> {}
 
    public async stop(): Promise<void> {}
}