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 | 4x 378x 378x 378x 4x 378x 378x 378x 378x 378x 4x | import * as Hashring from "hashring";
export interface ServerOptions {
basicAuth: BasicAuth;
}
export interface BasicAuth {
username: string;
password: string;
}
const defaultServerOptions: Partial<ServerOptions> = {};
function parseUrl(url: string): Record<string, string | number> {
const [host, portStr] = url.split(":");
const port = parseInt(portStr, 10);
return { host, port };
}
export class Server {
public url: string;
public host: string;
public port: number;
private _options: ServerOptions;
constructor(url: string, options?: Partial<ServerOptions>) {
this.url = url;
const { host, port } = parseUrl(url);
this.host = host as string;
this.port = port as number;
this._options = { ...defaultServerOptions, ...options } as ServerOptions;
}
}
export type ServerConfigs = Record<string, number | ServerConfig>;
export type ServerConfig = Partial<Hashring.ServerConfig & ServerOptions>;
|