All files / src/endpoint/html instance-details.ts

25% Statements 4/16
100% Branches 0/0
0% Functions 0/3
25% Lines 4/16

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 42 43 44 45  2x 2x 2x                                                                               2x  
import Node from 'type/node';
import HtmlEndpoint from 'endpoint/html';
import FetchNodeOperation from 'operation/fetch-node';
import InstanceDetailsTemplate from 'template/page/instance-details';
 
class HtmlInstanceDetailsEndpoint extends HtmlEndpoint<Record<string, never>> {
	protected async process(): Promise<string> {
		const node = await this.fetchNode();
 
		return this.renderNode(node);
	}
 
	private fetchNode(): Promise<Node> {
		const id = this.getUrlParameter('id');
		const type_id = this.getUrlParameter('type_id');
		const repository = this.getRepository();
		const account = this.getAccount();
 
		const input = {
			id,
			type_id,
			repository,
			account
		};
 
		const operation = new FetchNodeOperation(input);
 
		return operation.perform();
	}
 
	private renderNode(node: Node): string {
		const account = this.getAccount();
 
		const template = new InstanceDetailsTemplate({
			node,
			type_nodes: [],
			account
		});
 
		return template.render();
	}
}
 
export default HtmlInstanceDetailsEndpoint;