OpenAuth_server/src/views/login.ts

40 lines
845 B
TypeScript
Raw Normal View History

2020-08-07 14:16:39 +00:00
import * as handlebars from "handlebars";
2019-12-16 13:02:51 +00:00
import { readFileSync } from "fs";
2020-08-07 14:16:39 +00:00
import { __ as i__ } from "i18n";
2019-12-16 13:02:51 +00:00
import config from "../config";
let template: handlebars.TemplateDelegate<any>;
function loadStatic() {
let html = readFileSync("./views/out/login/login.html").toString();
template = handlebars.compile(html);
}
/**
* Benchmarks (5000, 500 cuncurrent)
* Plain:
* - dev 10sec
* - prod 6sec
* Mustache:
* - dev : 15sec
2020-08-07 14:16:39 +00:00
* - prod: 12sec
*
2019-12-16 13:02:51 +00:00
* Handlebars:
* Compile + Render
* - dev 13sec
* - prod 9sec
* Compile on load + Render
* - dev 13sec
* - prod 6sec
*/
export default function GetLoginPage(__: typeof i__): string {
if (config.core.dev) {
2020-08-07 14:16:39 +00:00
loadStatic();
2019-12-16 13:02:51 +00:00
}
2020-08-07 14:16:39 +00:00
let data = {};
return template(data, { helpers: { i18n: __ } });
2019-12-16 13:02:51 +00:00
}
2020-08-07 14:16:39 +00:00
loadStatic();