39 lines
799 B
TypeScript
39 lines
799 B
TypeScript
import * as handlebars from "handlebars"
|
|
import { readFileSync } from "fs";
|
|
import { __ as i__ } from "i18n"
|
|
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
|
|
* - prod: 12sec
|
|
*
|
|
* Handlebars:
|
|
* Compile + Render
|
|
* - dev 13sec
|
|
* - prod 9sec
|
|
* Compile on load + Render
|
|
* - dev 13sec
|
|
* - prod 6sec
|
|
*/
|
|
|
|
export default function GetLoginPage(__: typeof i__): string {
|
|
if (config.dev) {
|
|
loadStatic()
|
|
}
|
|
|
|
let data = {}
|
|
return template(data, { helpers: { "i18n": __ } });
|
|
}
|
|
|
|
loadStatic() |