import HttpHeader from 'http/enum/header'; import AccountNode from 'type/node/account'; import buildCookie from 'http/utility/build-cookie'; import HtmlEndpoint from 'endpoint/html'; import LogoutPageTemplate from 'template/page/logout'; class HtmlLogoutEndpoint extends HtmlEndpoint> { protected async process(): Promise { this.clearCookie(); const account = await this.loadAnonymousAccount(); const template = new LogoutPageTemplate({ account }); const html = template.render(); return Promise.resolve(html); } private clearCookie(): void { const cookie = buildCookie('', 0); this.setHeaderValue(HttpHeader.SET_COOKIE, cookie); } private loadAnonymousAccount(): Promise { const repository = this.getRepository(); return repository.fetchAnonymousAccount(); } } export default HtmlLogoutEndpoint;