Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (20 sloc) 574 Bytes
//hacky express wrapper thingy.
const fs = require('fs');
const path = require('path');
import {renderModuleFactory} from '@angular/platform-server';
const templateCache = {};
export function ngExpressEngine(setupOptions){
return function(filePath, options, callback){
if(!templateCache[filePath]){
let file = fs.readFileSync(filePath);
templateCache[filePath] = file.toString();
}
renderModuleFactory(setupOptions.bootstrap[0], {
document: templateCache[filePath],
url: options.req.url
})
.then(string => {
callback(null, string);
});
}
}